Uses ipify to get your public ip and Cloudflare API to update a DNS record.
Note; you will need an existing record in order to change it. Does not create records
Create .env file and add your GLOBAL_KEY, ZONE_ID, RECORD_ID, EMAIL and NAME in the same direcotry as main.py
GLOBAL_KEY="<GLOBAL_KEY>"
ZONE_ID="<ZONE_ID>"
RECORD_ID="<RECORD_ID>"
EMAIL="<EMAIL>"
NAME="<NAME>"
Run the script and you'll see the DNS record has changed
» python3 main.py
DNS record changed for <NAME> to <public ip>
See Overwrite DNS Record for list of options availabe that can be updated. Add these to the data dictionary.
data = {
'content': public_ip,
'name': NAME,
'type': 'A',
'id': RECORD_ID,
'comment': 'Updated automatically via script'
}