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 here if you need to accomplish this using LibCloud, or here if you are using a supported provider.
The Steps ∞
-
First, we will need to install Python
# Debian/Ubuntu/Vyatta/EdgeOS sudo apt-get install python # RedHat/CentOS/Fedora sudo yum install python
-
Download this script to
/config/scripts/cloudflare.py
-
Create a new file
/config/scripts/ddns.py
, and paste 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.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
/etc/dhcp3/dhclient-exit-hooks.d/ddns.py
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:
#/etc/dhcp3/dhclient-exit-hooks.d/ddns.py
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
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`