How to setup Dynamic DNS with Cloudflare in 21 easy steps

The question is… why would you want a Dynamic Domain Name System (DDNS)?

Here are 5 reasons why you would want a DDNS:

1. Dynamic IP Addressing:

  • Many residential and consumer ISPs assign dynamic IP addresses, which can change unexpectedly.
  • Static IP addresses are typically assigned to businesses.

2. Accessing Home Labs:

  • DDNS allows you to access your home network or lab through a domain name, even when your IP address changes.

3. Hosting Websites/Services:

  • If you host websites or services at home or on a personal server, DDNS ensures that your domain name always points to the correct IP address.

4. Secure Connections:

  • By updating your DNS records automatically, DDNS helps to maintain security and prevent connection disruptions.

5. Simplified Networking:

  • With DDNS, you can easily remember and use a domain name instead of remembering and updating IP addresses.

21 Easy Steps

Ready to set up Dynamic DNS with Cloudflare? Follow these steps:

  1. Get a Linux Box: Use a Linux-based system like Ubuntu or even a Raspberry Pi.
  2. Clone the Repository: Clone the following repository by K0p1-Git: cloudflare-ddns-updater.
  3. Change Directory: Navigate into the cloned directory and rename to a name of your choice.
  4. Edit the Script: Open the file in your favorite IDE or text editor. Before you start editing, log in to Cloudflare to get your Global API token and Zone ID.
  5. Fill in Your Details: Input your Cloudflare details into the script and save the file.
  6. Make the Script Executable: Run sudo chmod +x to make the script executable.
  7. Test the Script: Go back Cloudflare and change your DNS A record to and save.
  8. Run the Script: Go back to your terminal and execute bash
  9. Verify the Change: Refresh your DNS records in Cloudflare to see if the IP has been updated.
  10. Set Up a Cron Job: Automate the script by setting up a cron job. This will run the script at specified intervals to update your IP address.
  11. Update Your System: Update your Linux box with sudo apt-get update && sudo apt-get upgrade.
  12. Install Cron: If cron isn’t installed, install it using sudo apt-get install cron.
  13. Check Cron Status: Verify that cron is running with sudo systemctl status cron.
  14. Enable Cron on Startup: Ensure cron starts on boot with sudo systemctl enable cron.
  15. Create a Cron Job: Edit your cron jobs by running crontab -e.
  16. Add the Job: Add the following line at the bottom: * * * * * /usr/bin/bash /home/user/Projects/cloudflare-ddns-updater/ This example runs the script every mintue for testing purpose. Adjust as needed and save your changes. visit here to define your timings.
  17. Restart Cron: Restart cron to apply the changes with sudo systemctl restart cron.
  18. Check Cron Status Again: Go back to step 13 and verify that cron is still running.
  19. View Cron Jobs: List your cron jobs with crontab -l.
  20. Test Again: Go back to Step 7 and change your DNS A record to and save.
  21. Wait and Verify: Wait for a minute and check if your IP address is updated. If so, you’ve successfully set up your own DDNS.

Following these steps will ensure your dynamic DNS is properly configured with Cloudflare. Enjoy your automated IP updates!


Tips and tricks

Comments are closed