Last active
October 8, 2022 14:12
-
-
Save Rajdave69/e22dc4094bf143efff075a0cb399e198 to your computer and use it in GitHub Desktop.
A simple DDNS (Dynamic DNS) Script for 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
""" | |
This is a public script made by RajDave69 on GitHub | |
This script implements DDNS (Dynamic DNS) for users using CloudFlare. | |
It's super easy to configure and deploy too! Just run it as a daemon. | |
""" | |
from cloudflare_ddns import CloudFlare | |
import time | |
email = "" # Your cloudflare Email | |
api_key = "" # Needs to be the "Global API Key" from https://dash.cloudflare.com/profile/api-tokens | |
domain = "" # The domain you want DDNS to be for | |
try: | |
cf = CloudFlare(email, api_key, domain) | |
except: | |
while True: | |
try: | |
cf = CloudFlare(email, api_key, domain) | |
break | |
except: | |
print("Can not establish connection to CloudFlare. Retrying in 60 seconds") | |
time.sleep(60) | |
def update_dns(): | |
try: | |
print(time.strftime("%d/%m/%Y %H:%M:%S", time.localtime()), end=" | ") | |
e = cf.sync_dns_from_my_ip() | |
except Exception as e: | |
print(time.strftime("%d/%m/%Y %H:%M:%S", time.localtime()), end=" | ") | |
print(e) | |
while True: | |
try: | |
update_dns() | |
except SystemExit: | |
pass | |
except Exception as e: | |
print(time.strftime("%d/%m/%Y %H:%M:%S", time.localtime()), end=" | ") | |
print(e) | |
time.sleep(300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment