Cloudflare DDNS Updates (Aug 2018 Edition)

In one of my old blog posts I covered some scripts to update Cloudflare’s DNS system. This is useful if you’re hosting sites at home on a Raspberry PI (like this one still is!), where you might not have a static IP.

In the intervening 3 years, the API has changed, so I’ve revisited the scripts to update them to the new shiny “Cloudflare API V4”. The updated scripts are tested on the current latest image of Raspbian Stretch at the time of writing. The new scripts are available on GitHub here.

The structure of the scripts is still the same:

  • is the main update script, intended to be setup to run automatically via crontab or similar.
  • is used to read the host id value from the host record that needs updating (while Cloudflare mention some API details and stubs of requests in the API section of the DNS dash page, there still doesn’t seem to be a nice way to get this id. Its just mentioned as “:identifier” in those stubs).

If they break again and I don’t notice, or if there are any problems with the scripts, please raise an issue on the Github Repo.

CloudFlare DDNS updates

This blog is hosted on a Raspberry Pi under my TV at home. As is common with this scenario I have a dynamic WAN IP, updating intermittently at the whim of my ISP/router.

After a few attempts I’ve finally got a stable DDNS update that works with CloudFlare (having had trouble with various bits of ddclient+patches etc) in the form of some scripts that call curl against the Api directly. This seems nice and neat, and the scripts can be scheduled using cron.

I’ve posted the scripts used here. I’ll try to keep these updated as the CloudFlare Api changes (as I’ll have to to keep the site running!).

I’ve included the script required to download details of the dns records from CloudFlare, as this is required to get the rec_id value for the dns entry, which is then sent back for the update. My version of the main update script also maintains a simple log file of updates.

The repo is here, the update script is here
and the read script is here