If you have a Dynamic Public IP from your ISP and use Cloudflare as your DNS provider you could use DDclient to update the A-record IP on Cloudflare every time the Public IP changes. This is very convenient as you don’t have to to anything yourself every time your IP address gets updated. It’s all done automatically!
In our setup we use one A-record for each domain and have everything else as CNAME’s so that we only have to update in one place in case our IP should change for some reason. This also means that with DDclient you only have to check the root domain as the A-record determinants the address for the CNAME’s (subdomains). Though it took us a while to figure out how to use multiple accounts in the same conf file. So to spare you the googling here is how it’s done on Ubuntu 16.04:
Install DDclient and needed dependencies via CLI
$~: sudo apt install ddclient libjson-any-perl ssh libio-socket-ssl-perl
If it’s asking you to configure something, just keep hitting “esc” until it’s done. We will change the config file later anyway.
Download the latest version of DDClient from Sourceforge. Preferably use wget in your CLI
$~: wget http://downloads.sourceforge.net/project/ddclient/ddclient/ddclient-3.8.3.tar.bz2 && tar -jxvf ddclient-3.8.3.tar.bz2
Overwrite the existing ddclient binary
$~: sudo cp -f ddclient-3.8.3/ddclient /usr/sbin/ddclient
Since the dir has changed in the later versions of DDClient we have to create it and move the conf file there
$~: sudo mkdir /etc/ddclient && sudo mv /etc/ddclient.conf /etc/ddclient
Now let’s create a conf file
$~: sudo nano /etc/ddclient/ddclient.conf
The conf file should look like this with multi account
You can find your API key to Cloudflare here. Please note that it important to not add extra spaces or special signs. It will give you warnings.
# Global settings for Cloudflare use=web web=checkip.dyndns.com/ web-skip="IP Address" daemon=600 syslog=yes pid=/var/run/ddclient.pid cache=/tmp/ddclient.cache protocol=cloudflare server=www.cloudflare.com ssl=yes # Tech and Me login=your-email-address-account-1 password=your-cloudflare-global-API-key-account-1 zone=techandme.se techandme.se zone=domain.nu domain.nu # Domain 2 login=your-email-address-account-2 password=your-cloudflare-global-API-key-account-2 zone=domain.com domain.com
Test your settings
$~: sudo ddclient -daemon=0 -debug -verbose -noquiet
Add a crontab just in case
$~: sudo crontab -e -u root
37 04 * * * /usr/sbin/ddclient --force
Restart DDclient and check your status
$~: sudo /etc/init.d/ddclient restart && sudo /etc/init.d/ddclient status
If everything is OK it should look something like this:
[email protected]:/etc/ddclient# sudo /etc/init.d/ddclient restart [ ok ] Restarting ddclient (via systemctl): ddclient.service. [email protected]:/etc/ddclient# sudo /etc/init.d/ddclient status ● ddclient.service - LSB: Update dynamic domain name service entries Loaded: loaded (/etc/init.d/ddclient; bad; vendor preset: enabled) Active: active (running) since Fri 2017-04-14 22:21:35 CEST; 4s ago Docs: man:systemd-sysv-generator(8) Process: 12775 ExecStop=/etc/init.d/ddclient stop (code=exited, status=0/SUCCESS) Process: 12785 ExecStart=/etc/init.d/ddclient start (code=exited, status=0/SUCCESS) CGroup: /system.slice/ddclient.service ├─11048 ddclient - sleeping for 70 seconds ├─11783 ddclient - sleeping for 100 seconds ├─12095 ddclient - sleeping for 100 seconds ├─12367 ddclient - sleeping for 20 seconds └─12792 ddclient - sleeping for 300 seconds Apr 14 22:21:35 NGNIX systemd: Starting LSB: Update dynamic domain name service entries... Apr 14 22:21:35 NGNIX systemd: Started LSB: Update dynamic domain name service entries.
Now everything is setup. Enjoy!