Linux notes

Using ddclient to keep your static IP address up-to-date

If, as many do, you want to access your home network from 'outside' (i.e, when you are travelling or otherwise not 'on' your local network), or you wish to run some sort of server that others can easily access, you naturally want to associate a domain name with the IP address associated with you by your service provider. You can use services such as those provided by DynDNS for this; they will let you choose a memorable domain name (say, mygreatsite.dyndns.org) and map that to your current IP address.

This works well if the IP address given to your internet connection by your ISP never changes. Unfortunately, most will change at some time or another, and some change so often that keeping track of them is next to impossible. Naturally, as soon as this change occurs, the convenient link between the domain name (mygreatsite.dyndns.org in our example) and your actual IP address of the moment is broken. Not so convenient!

To solve this problem, we'd like to find some sort of program that would detect any changes in your current IP address and automatically update the DynDNS record (or the equivalent, if not using their service). Fortunately there exists exactly this, in the form of ddclient - a Perl client that handles the address checking and updating automatically.

Installing and using ddclient

Using apt-get

If you are using apt-get, installation is trivial:
apt-get install ddclient
During the installation process, you will be asked for some details of your network and your DynDNS (or whatever) account. These are: Finally, you'll be asked if you want to run ddclient as a service at startup. You should answer yes.

Manual install

If you want the latest version, which has many more nice features than the current release in Debian Sarge (stable), follow the procedure below.

ddclient creates a configuration file in /etc/ddclient.conf. You can edit this file if you need to change any of the configuration details. If you are using a program such as monit to keep an eye on your machine, you'll find the process identifier (.pid) file at /var/run/ddclient.pid.

Usage

ddclient will run at startup and monitor the IP address of your network adapter at the interval you specified in your setup. If the IP address changes, it will contact DynDNS or other DNS provider and automatically update the record to keep your domain name pointing to your new IP address. You don't have to take any action to allow this to happen.

Helpfully, ddclient sends an email to the default user on the machine on which it is installed, whenever it performs an update or encounters a problem. Typical messages report a successful update or a problem (for example, it was unable to contact the DynDNS site for some reason).

All in all, ddclient is a very useful program that solves a tricky problem. I use it on both my firewall machines.