This script is used to update Dynamic DNS (DDNS) service based on Cloudflare! Access your home network remotely via a custom domain name without a static IP! Written in pure BASH.
This fork is an amendment to cloudflare-ddns-updater
adding a function that checks if the IP has changed, as there is no need to update the DNS record since it already points to the correct IP address. This check helps reduce unnecessary API calls to Cloudflare and saves resources.
On the other hand, if the IP is changing, the script will log this IP into the current-ip.txt
file and go ahead with updating the DNS record using the new IP.
git clone https://github.com/olgv/cloudflare-ddns-updater.git
Update your details requested in lines 4-14 (4-8 are compulsory).
Note: I had to use an
API Token
not aGlobal API Key
in CloudFlare, and keep the script totoken
on line 5.
This script is used with crontab
crontab -e
Specify the frequency of execution through crontab
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday 7 is also Sunday on some systems)
# │ │ │ │ │ ┌───────────── command to issue
# │ │ │ │ │ │
# │ │ │ │ │ │
# * * * * * /bin/bash {Location of the script}
Make sure you make both the script cloudflare-template.sh
(or how ever you decide to call it) and the current-ip.txt
file editable by using:
chmod +x cloudflare-template.sh
chmod +x current-ip.txt
and keep the two files together, in the same place.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This script is an amendment to the original cloudflare-ddns-updater
. Support by K0p1-Git via PayPal here.
This script was also made with reference from Keld Norman video.