cloudflare-ddns Update/create Cloudflare records with an A record pointing to the public IP of the host. Records are specified by listing a zone with -z followed by a list of unproxied (-r) or proxied (-p) records (full domain format), see OPTIONS. Multiple zones and records can be specified, see EXAMPLE. Recommended to be ran in a crontab every 5 minutes. The public IP is determined by using the endpoint 'api.ipify.org', which returns the public IP in plain text. The IP is cached to '/tmp/cloudflare-ddns-public-ip' in order to only make Cloudflare API requests when on IP change. Both the endpoint and caching behavior can be changed, see ADVANCED OPTIONS. Script output is minimal, only when the IP changes does the script report results. If you intend to notify only on IP changes/record updates then conditionally doing so on any output will suffice. REQUIREMENTS: * jq (apt install jq / pacman -S jq / brew install jq). * Cloudflare zone already configured. * Cloudflare API token with permissions: * Zone.Zone * Zone.DNS USAGE: cloudflare-ddns.sh [OPTIONS] -t <token> -z <zone> -r <record>... OPTIONS: -t <token> Cloudflare token, can also be set with environment variable CLOUDFLARE_API_TOKEN. -z <zone> Zone name (full domain, excluding subdomains) for proceeding records. -r <record> New/existing record name for preceding zone containing entire domain, e.g. foo.bar.com. -p <record> Like -r (above), but record will be Cloudflare proxied. ADVANCED OPTIONS: -i <new ip> Skip checking endpoint for public IP and use specified instead. -I <old ip> Skip checking the cached old public IP and use specified instead. -E <endpoint> Override default curl endpoint to determine public IP, must return in plain text. -C <cache file> Override default IP cache file and use specified instead. Specify \"\" to disable caching. EXAMPLE: cloudflare-ddns.sh -t <token> -z bar.com -r foo.bar.com -p foo2.bar.com -z y.com -p y.com -p www.y.com Set the A records of the listed domains across two zones to be the current public IP. foo2.bar.com, y.com, and www.y.com will be proxied by Cloudflare (denoted by -p), foo.bar.com will not (denoted by -r).
harrego/cloudflare-ddns
Cloudflare dynamic DNS shell script with support for multiple zones and records
ShellMIT