This repo contains everything you need to get a simple DDNS service running for your home server using the Cloudflare API.
It automatically updates your Cloudflare DNS records with your current public IPv4 and IPv6 addresses. We use systemd's encrypted credentials feature to store API tokens and identifiers.
- Ensure you have
xhandjqinstalled and are on a system with systemd. - Create
AandAAAArecords on the Cloudflare dash or with the API. These can have any value for now. - Obtain the following:
- Record ID for aforementioned
AandAAAArecords. You can find these withlist_records.shor by manually using the Cloudflare API. - Cloudflare zone ID for your domain (you can find this in the Cloudflare dash).
- Cloudflare Account API token with the Zone.DNS permissions.
- An ipinfo.io API key (this is needed since we're grabbing both IPv4 and IPv6 IPs).
- Record ID for aforementioned
- Run
sudo make set-secretsand paste the required variables. - Run
sudo make install.
watch logs:
sudo journalctl -u cloudflare-ddns.service -f
systemctl status cloudflare-ddns.timer
systemctl status cloudflare-ddns.service # NOTE: This probably won't be active since it gets started/stopped by the timercheck service status:
systemctl status cloudflare-ddns.timer
systemctl status cloudflare-ddns.service # NOTE: This probably won't be active since it gets started/stopped by the timersudo make uninstall- cloudflare-ddns - Bash script that fetches current IP and updates DNS records
- cloudflare-ddns.service - Systemd service unit (oneshot)
- cloudflare-ddns.timer - Systemd timer (runs every 2 minutes)
- Encrypted Credentials - Stored in
/etc/cloudflare-ddns/
- OnBootSec=1min: First run 1 minute after system boot
- OnUnitActiveSec=2min: Subsequent runs every 2 minutes after previous completion
Edit cloudflare-ddns.timer and change OnUnitActiveSec= value:
sudo systemctl edit cloudflare-ddns.timer
sudo systemctl daemon-reload
sudo systemctl restart cloudflare-ddns.timerYou may wish to only expose/update your IPv4 address. In this case, you just have to delete the second function call in the main cloudflare-ddns script.
update_dns_record 'v4' "$CF_RECORD_ID_4"
-update_dns_record 'v6' "$CF_RECORD_ID_6"