Automatic Cloudflare DNS Update
Create a script that queries the current IP address, then updates it using Cloudflare's API
# Aquire the permanent, publically addressable ipv6 address of the eth0 adapter
ip -6 addr show dev eth0 mngtmpaddr | grep -oE "([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}"
# Aquire the ipv4 address
curl https://api.ipify.org
import http.client requests json
ipv4_data = json.loads(requests.get('https://api.ipify.org?format=json').text)
ipv4_addr = ipv4_data["ip"]
# Aquire the permanent, publically addressable ipv6 address of the eth0 adapter
ipv6_addr = subprocess.run('ip -6 addr show dev eth0 mngtmpaddr | grep -oE "([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}"')
# Aquire zones
conn = http.client.HTTPSConnection("api.cloudflare.com")
headers = {
'Content-Type': "application/json",
'Authorization': "Bearer <API_TOKEN>"
}
conn.request("GET", "/client/v4/zones", headers=headers)
res = conn.getresponse()
data = res.read()
# Modify all DNS records
...