Dynamic IP with DynDNS

By habrok

Tomorrow the slug will be moved to Valhall* and installed there. It will then connect directly to the internet and a DHCP server over which I have no control. This means I will have no knowledge over which IP address it is assigned and I cannot login to it with SSH as I do now.

Luckily I already have an account at DynDNS, so I will set up a dynamically updated IP address here and update it using the Perl-script ddclient. I won’t go into any details about this as it is really straightforward. I added the host suttung.godtjod.net ** to my zone, with a “dynamic” type (meaning we will change it with a update client).

Next, I installed the ddclient on the slug. It is already in the Debian repository, so just run:

sudo apt-get update
sudo apt-get install ddclient

You will be asked for the name of your host (suttung.godtjod.net in this case), your login and password at DynDNS, and which interface to get the IP-address from (eth0 is the built-in ethernet on the slug). In my case this failed to work, so I went on and edited the configuration file:

sudo nano -wL /etc/ddclient.conf

with the new file looking like:

#get IP number from interface eth0
use=if, if=eth0
#run as a daemon, updating every 5 minutes
daemon=5m
#log to syslog
syslog=yes
#keep pid in this file
pid=/var/run/ddclient.pid
#default protocol is dyndns2 (the current protocol for DynDNS.org)
protocol=dyndns2
#default server to update to
server=members.dyndns.org
#login and password to the DynDNS service
login=habrok
password='pa$$w0rd'

#host specification
protocol=dyndns2 \
server=members.dyndns.org \
#this is a custom DNS service (using my own domain)
custom=yes \
#the host to update
suttung.godtjod.net

I think it might be the “custom=yes” thing that did it, but I made all the changes at once so I don’t really know.

Now try out your configuration:

sudo ddclient

Check the web-interface at DynDNS to see if it is updated correctly; If it is, you should start the daemon to get periodic updates:

sudo /etc/init.d/ddclient start

Now, you might wonder if this is really working? Maybe your IP doesn’t change all too often so you can’t sit around waiting for it to change. Don’t worry. Just run ddclient manually to set another (and faulty) IP-address:

sudo ddclient -ip 10.10.10.10

Wait for the next update (5 minutes in our case) and check that the IP is back to what it should be.

No worries, eh?

* Valhall is a mock name, there isn’t really a place called that (not that I know of at least).

** You should choose a real name for your host, not one about what it is (like ’slug’) or what it does (like ‘fileserv’). Names like these may be good for remembering, but then you can always add an alias (a CNAME record) to your DNS.

Leave a Reply