Cloudflare Dynamic DNS update
A script for dynamically updating a CloudFlare DNS record.
https://stedolan.github.io/jq/
- Cloudflare account
- Cloudflare API key
- An A record belong to 1 zone managed by Cloudflare
To use this script, create a copy of the cloudflare_ddns.sh.template file (and remove .template from the filename).
Update below variable:
- domain='your_domain'
- zone='your_second&TLD_domain'
- email='your_email_address'
- api_key='your_api_key'
To do a one-off update of your DNS record, simply run this script from your terminal. The script will determine your public IP address and automatically update the CloudFlare DNS record along with it.
Because dynamic IPs can change regularly, it's recommended that you run this utility periodically in the background to keep the CloudFlare record up-to-date.
Just add a line to your crontab and let cron run it for you at a regular interval.
*/15 * * * * /path/to/code/cloudflare_ddns.sh >> /var/log/cloudflare_ddns.log 2>&1