Skip to content

Navigation Menu

Sign in
Sign up

Latest commit

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

alt text

Cloudflare DDNS curl scripts that call CF-API (v4) directly.

My third-party DDNS service stopped working recently with CF. It seems CF has moved to a new API (v4).

The very good news is you can ditch third-party DDNS and simply run a DDNS shell script as a cron job every minute on your webserver. It calls the new CF API directly.

This is a bare bones script that requires:

  • Internet connectivity is available.
  • CF API v4 service is available
  • api.ipify.org service is available

You need the Zone ID, Authorization key and A-record ID for your domain.

Fetch the first two from your CF account.

Create the A-record in CF named "dynamic".

Create the CNAME alias (example.com --> dynamic.example.com)

alt text

Fetch The A-record ID with cloudflare-dns-id.sh

Run cloudflare-ddns.sh as a cron job * * * * * /.../cloudflare-ddns.sh

Test by changing your A-record to a bogus IP and then deleting /tmp/ip-record The cron job will change the A-record to your webserver IP address on it's next run.

Marvel at your own dynamic dns service - no more surrendering your CF Authorization key to a third party DDNS service.

Note that the CNAME alias masks your real IP address - a fundamental advantage of CF. Naming the A-record directly as your domain (example.com) would allow anyone to see your real IP address just by ping example.com. Try it!

Note that you will need to update this script:

  • if your CF Zone ID, Authorization key, or A-record ID change. Only you can change these.
  • if CF API v4 is deprecated. It is currently new, so should be stable for many years.
  • if api.ipify.org is deprecated. There are many others. Or use dig if you like.

TO DO

  • Convert curl from linux bash script to other platforms.
  • DONE: Windows BAT

DO NOT commit your Authorization key to GitHub - thar be dragons. Purge any such commits and change your key.

alt text

About

Ditch your third-party DDNS service! Cloudflare DDNS curl scripts that call Cloudflare's API (v4) directly.

Topics

Resources

Stars

66 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /