Created
February 12, 2020 13:35
-
-
Save syeef/041f267ddcf8911a3035447687ae3f20 to your computer and use it in GitHub Desktop.
DynamicDNS with Cloudflare (Get current IP Address -> Update DNS record on Cloudflare)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from requests import get | |
key = <ENTER CF GLOBAL API KEY> | |
email = <ENTER CF LOGIN EMAIL> | |
zone_ID = <ENTER ZONE ID> | |
record_ID = <ENTER DNS RECORD ID> | |
ip = get('https://api.ipify.org').text | |
put = requests.put( | |
'https://api.cloudflare.com/client/v4/zones/{}/dns_records/{}'.format( | |
zone_ID, record_ID), | |
json={ | |
'type': 'A', | |
'name': <ENTER ZONE NAME>, | |
'content': ip, | |
'proxied': False | |
}, | |
headers={ | |
'X-Auth-Key': key, | |
'X-Auth-Email': email, | |
'Content-Type': 'application/json' | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment