Dynamic DNS With CloudFlare – Ubiquiti EdgeRouter

This tutorial will walk you through the process of setting up Dynamic DNS with CloudFlare on the Ubiquiti EdgeRouter (or really any form of Linux). Please see [[ddns-using-libcloud-edgerouter|here]] if you need to accomplish this using [[https://libcloud.apache.org/|LibCloud]], or [[dynamic-dns-with-ubiquiti-edgerouter|here]] if you are using a supported provider.

=== The Steps ===
# First, we will need to install Python
{{{ lang=bash
# Debian/Ubuntu/Vyatta/EdgeOS
sudo apt-get install python

# RedHat/CentOS/Fedora
sudo yum install python

# Download [[https://gist.github.com/lasley/dc19fc32f3377fe672bc5688d4a80382|this script]] to `/config/scripts/cloudflare.py`

# Create a new file `/config/scripts/ddns.py`, and paste [[https://gist.github.com/lasley/3857dfd338cda4860cb2|this script]]. Add your own information directly below the `# Edit here`:

# Add execution bit and create a hard link in dhclient exit hooks directory. These two commands will need to be rerun if you flash the ERL firmware. //Note that no execution bit is required on the `cloudflare.py` file.//
{{{ lang=bash
chmod +x /config/scripts/ddns.py &&
ln -s /config/scripts/ddns.py /etc/dhcp3/dhclient-exit-hooks.d/ddns.py

# Run the script in order to update DNS and verify that everything will work correctly
{{{ lang=bash

* [[https://gist.github.com/lasley/dc19fc32f3377fe672bc5688d4a80382|cloudflare.py]]
* [[https://gist.github.com/lasley/3857dfd338cda4860cb2|ddns.py]]



, , ,




2 responses to “Dynamic DNS With CloudFlare – Ubiquiti EdgeRouter”

  1. Philipo Ingram Avatar

    Thanks for this tutorial. I realize you wrote this quite some time ago but I’m curious if you know what would cause the following error:


    Traceback (most recent call last):
    File “/etc/dhcp3/dhclient-exit-hooks.d/ddns.py”, line 18, in
    from cloudflare import CloudFlare
    ImportError: No module named cloudflare

    I can see the linked ddns.py file but not the cloudflare one. Additionally, we are left to assume what owner and permissions should be set on both of these files? I can see the chmod +x on one but nothign on the other. Thanks

    1. Dave Lasley Avatar

      Apologies for the dup comments, but it turns out this was quite a while ago – before the actual library existed, in fact. The cloudflare.py file is the library in use here, and there is no execution bit required on it.

      As long as it is in the same directory as the ddns.py, there shouldn’t be any issues. The culprit here was actually the symlink, it needed to be a soft link not a hard link. Try removing the link then `ln -s /config/scripts/ddns.py /etc/dhcp3/dhclient-exit-hooks.d/ddns.py`

Leave a Reply

Your email address will not be published. Required fields are marked *