• Post last modified:May 19, 2020
  • Post Comments:0 Comments

Automatically Update Public IP Addresses in Cloudflare

Introduction

If you’ve followed my previous guide on setting up a reverse proxy that leverages Cloudflare’s DNS capabilities or if you’re already doing so for other projects, you’ll note a major pain-point in the process of having to manually update your domain’s A record every time your public IP address changes.

Well, it turns out there’s a Docker application we can leverage called Cloudflare-DDNS that will automate the process for us (granted the server running the application is online when the IP address changes).

As usual, this guide will be geared towards Unraid because that’s what I run on my home server, but the service is available to anyone running an operating system capable of installing Docker applications.

One last thing before we get started: I’ll note that people often seek this functionality from a spare Raspberry Pi they have laying around the house. While Raspberry Pi’s are lower overhead and maintenance, I’ve chosen to leverage this functionality in my server through Unraid because it’s always running anyway and also because it’s easier to set up and manage.

What We’ll Need

We won’t need much for this tutorial, but I will assume you already have a few things set up in order to proceed:

  • A Cloudflare account with DNS records pointing to an IP address (the free account is fine for this)
  • A server running Unraid (or any other Linux-based operating system)
  • Access to the Community Applications plugin in Unraid to install the Cloudflare-DDNS Docker image from

If you want to test this application is working after we install it without having to change your IP address, go ahead and plug a dummy IP address into your Cloudflare’s A record (something like 1.1.1.1), but only if you can afford for your websites to go down for a few minutes while we set it up.

Once we install the application, you should notice your IP address update in Cloudflare and is how you’ll know it’s working properly.

Installing Cloudflare-DDNS

Navigate to the ‘Apps’ tab in Unraid and search for “Cloudflare-DDNS”. You’ll see several options appear – I’ve installed the container maintained by oznu, but I’m sure the others are fine if you’d rather install those instead (although the installation instructions may vary slightly from what I’ve documented below).

Click the installation button and edit the following installation parameters:

  • E-mail: This should be the e-mail of your Cloudflare account
  • API Key: This can be found within the settings of your Cloudflare account
  • Domain: The base domain of the DNS record you would like to update (exampledomain.com, etc.).
  • Subdomain: Any subdomains you’d optionally like updated as well (although best practice is to set subdomains up as CNAME records that point to the A record so only one record needs updated when the IP address changes)
  • Cloudflare Proxy: False
  • IPv6/IPv4 records: “A” for IPv4 records (most common) or “AAAA” for IPv6 records

Click “Apply” and the application will install.

Confirm the Application Installed Correctly

If you followed the directions above, everything should be working. If you set your A record to 1.1.1.1 as recommended at the beginning of this guide for testing purposes, you should notice the record change back to your actual IP address.

If you didn’t change your A record’s IP address, you can utilize the container’s logs to confirm it is working and monitoring for IP address changes.

If something isn’t working correctly, feel free to comment below. There is no web interface for this application, so the logs will need to be leveraged for troubleshooting purposes.

Conclusion

That should be it – the application is now installed and monitoring the network for public IP address changes.

Feel free to dedicate your time to some other monotonous task now that you’ll no longer need to monitor your IP address on a regular basis!

If you’ve found this or any of the other posts on SHIFT14 helpful, please consider supporting the site through a one-time PayPal donation or ongoing support through Patreon. My goal is to continue providing in-depth guides for the technical community and the support helps justify the time and resources spent doing so.

Leave a Reply