CloudFlare is the perfect dynamic DNS host because, unlike the other major ones, CloudFlare is completely free. Unfortunately if your ISP dosen’t allow use of a static IP, maintaining regular internet uptime can be quite annoying. Here’s how I got DDNS working on Ubuntu 18.04.1 LTS with Cloudflare and ddclient running as a daemon to check and renew our IP if it changes.
sudo apt install ddclient libdata-validate-ip-perl
Install with the below options
- Dynamic DNS service provider: select other
- Dynamic DNS server: leave blank
- Dynamic DNS update protocol: select dyndns2
- Username for dynamic DNS service: leave blank
- Password for dynamic DNS service: leave blank
- Re-enter password to verify: leave blank
- Network interface used for dynamic DNS service: leave blank
- DynDNS fully qualified domain names: leave blank
Now let’s rerun the configuration and answer the additional questions that were not asked on the first run! You can just provide the same answers, but the additional questions are what we need to pay attention to.
sudo dpkg-reconfigure ddclient
- Run ddclient on PPP connect?: select No (the default is “Yes”).
- Run ddclient as a daemon: select Yes (the default is “No”).
- Interval between ddclient runs: leave as 300 (if you want a 5 minute interval).
Since the Ubuntu repository installs ddclient version 3.8.3 (released 2015-05-30), and the latest version is 3.9.0 (released 2018-08-09), we should probably update it.
tar -xvf ddclient-3.9.0.tar.gz
Overwrite our existing 3.8.3 install
sudo cp -f ddclient-3.9.0/ddclient /usr/sbin/ddclient
The ddclient.config file location has changed in 3.9.0, so we need to resolve that issue.
sudo mkdir /etc/ddclient
sudo mv /etc/ddclient.conf /etc/ddclient
Let’s cleanup by removing the old package files
rm -R ddclient-3.9.0
sudo nano /etc/ddclient/ddclient.conf
Let’s review and update the config values.
# Configuration file for ddclient generated by debconf # # /etc/ddclient.conf # For more information, see https://jacobjangles.com/free-ddns-using-ddclient-and-cloudflare/ daemon=900 ssl=yes protocol=cloudflare use=web login=YOUR-CLOUDFLARE-EMAIL-ADDRESS password=YOUR-CLOUDFLARE-API-KEY zone=dotmycom.com ( replace with your domain ) dotmycom.com ( replace with your domain )
Google your IP address and verity it matches below.
sudo ddclient -query
Verify that ddclient is returning your correct ip address (10.10.10.10 is our example).
use=if, if=enp2s0f0 address is 10.10.10.10 use=if, if=lo address is 127.0.0.1 WARNING: found neither ipv4 nor ipv6 address use=web, web=dnspark address is NOT FOUND use=web, web=dyndns address is 10.10.10.10 use=web, web=loopia address is 10.10.10.10
Try to update your DNS records for the first time.
sudo ddclient -daemon=0 -verbose -noquiet
You will see the following output:
CONNECT: checkip.dyndns.org CONNECTED: using HTTP SENDING: GET / HTTP/1.0 SENDING: Host: checkip.dyndns.org SENDING: User-Agent: ddclient/3.9.0 SENDING: Connection: close SENDING: SENDING: RECEIVE: HTTP/1.1 200 OK RECEIVE: Content-Type: text/html RECEIVE: Server: DynDNS-CheckIP/1.0.1 RECEIVE: Connection: close RECEIVE: Cache-Control: no-cache RECEIVE: Pragma: no-cache RECEIVE: Content-Length: 105 RECEIVE: RECEIVE: <html><head><title>Current IP Check</title></head><body>Current IP Address: 10.10.10.10</body></html> SUCCESS: dotmycom.com: skipped: IP address was already set to 10.10.10.10.
Pay attention to the last line. Note the SUCCESS:
If you do have problems, you can get a lot more information by running:
sudo ddclient -daemon=0 -debug -verbose -noquiet
ps ax | grep ddclient
You will see the following output:
1471 ? S 0:00 ddclient - sleeping for 310 seconds 5613 pts/0 S+ 0:00 grep --color=auto ddclient
You can see ddclient is active and waiting to update. If it’s not running as a daemon, the file /etc/default/ddclient will probably need to be adjusted and you might need to make a Unit File. Check out running ddclient as a service.