ddclient for DynamicDNS
June 19, 2024
Installation
sudo apt install ddclient
service ddclient start
service ddclient status
File list
Config file | Purpose |
---|---|
/etc/ddclient.conf | Your personal configuration file where your setup questions went to.Use this file to setup other dynamic DNS providers |
/etc/init.d/ddclient | The daemon file which can run the ddclient as a daemon (service) |
/default/ddclient/etc | The global parameter file |
/usr/share/doc/ddclient/examples/sample-etc_rc.d_init.d_ddclient.ubuntu | Some documentation which came with the package |
Add No IP
sudo nano /etc/ddclient.conf
In that file just add:
use=web
ssl=yes
protocol=noip
login=<USERNAME>
password=<PASSWORD>
<YOUR_HOSTNAME>,<YOUR_HOSTNAME>,<YOUR_HOSTNAME>
Check status
sudo ddclient -query
or
sudo ddclient -debug -verbose -noquiet
Run ddclient as a daemon
Since we don’t just want the IP address to update once, we still need to set up ddclient to run as a daemon so it can check for a change of IP address periodically and notify the dynamic DNS provider if necessary. To start the daemon we need to open another configuration file, /etc/default/ddclient
and set:
run_daemon="true"
You will notice there is a daemon_interval
parameter there too, I think the default value of 300 seconds (5 minutes) is reasonable, so I didn’t change it. Save and close the file, and then run:
sudo service ddclient start
to start the daemon, and:
sudo service ddclient status
to check its status. ddclient keeps a cache of your IP address, and it will only update the record with your dynamic DNS provider if your IP address has changed. Since some ISPs seem to only allocate new IP addresses when the modem is power cycled, and some dynamic DNS providers will time out if you don’t update the record in a while, there is one thing left to do – we need to add a cron job to force an update weekly, just in case. Choose whether you want to force an update daily or weekly, and then create a file called ddclient in the relevant directory, e.g. /etc/cron.daily
or /etc/cron.weekly
:
sudo nano /etc/cron.daily/ddclient
Fill in this information:
#!/bin/sh
/usr/sbin/ddclient -force
Then make the script executable:
sudo chmod +x /etc/cron.daily/ddclient