Advanced Dynamic DNS with ddclient

If you need remote access to a computer whose IP changes dynamically, ddclient may be the tool for you. Check out this previous article for how to set up ddclient using a free service like DynDNS. Once set up, you will be able to connect to your box using a pretty name like, rather than having to keep track of the changing IP. I should mention that there are many other free DNS services besides, and that many home routers can take care of Dynamic DNS for you (i.e., you can set it up on the router, rather than on your computer).

Today, however, we have a more complicated task. This article will teach you how to:

  • make ddclient update multiple host names
  • make ddclient update the IP of multiple interface (e.g., your ethernet and your wireless lan)
  • set up ddclient so that it updates correctly regardless of whether you are on a wired or wireless connection
  • make ddclient use either your interface address (may be local, e.g. or the address that is visible from the internet.

First, let me explain my use case. At home, I have a router that forwards SSH connections to my laptop, which is behind a NAT. Here, I want remote connections to use the router’s address (i.e., the web-visible address, not the address that my laptop’s interface gets). In the lab, I am also behind a NAT, but the NAT server is outside of my control, and I cannot set up forwarding. Here, I want connections from other lab machines (which are behind the same NAT) to use my laptop’s local interface address, rather than the web-visible address of the NAT server. At both locations, I get a dynamic IP, and I may use either a wired or a wireless connection.

This means that I need two domain names: (these are example names; don’t even think about it)

  •, which gets updated with my web-visible address (i.e., the one I would see by going to, and
  • which gets updated with my local address (i.e., the one I would see if I ran ifconfig).

To make things more complicated, this needs to work regardless of whether I am using the ethernet or the wireless connection. After some googling, I was pleasantly surprised to find out that ddclient can do this. Here is my config file, with explanations following.

# /etc/ddclient.conf


# updates internet ip on either wireless or wired
use=web, \, \
protocol=dyndns2, \
login=..., \
password=...        \

# updates interface (maybe local) ip on either wireless or wired
use=cmd, cmd=find-local-ip, \, \
protocol=dyndns2, \
login=..., \
password=...        \

I am using a little-known feature that allows ddclient to update multiple IPs / hosts. For, I use=web, which means that ddclient will take my IP from This works regardless of whether I am on the wired or wireless connection, which is exactly what I want. For, I use=cmd, cmd=find-local-ip, where find-local-ip is a simple script that looks like this:

ifconfig eth0
ifconfig wlan0

Ddclient will search the output of ifconfig eth0; ifconfig wlan0 and select the first string that looks like an IP. This is necessary because with use=if, you can only specify one interface. Note that I could not just use cmd=ifconfig, because then ddclient might pick the of the local loopback interface.

You can modify the above to suit your needs. For example, if you have two wired interfaces with different IPs, you may want to update two host names, one per interface. Remember to run ddclient -v to verify that your config file does what you want.

2 Responses to Advanced Dynamic DNS with ddclient

  1. freedns says:

    Dou might consider referencing an up to date list of Dynamic DNS / Free DNS providers so folks can choose from various services out there. The best resource for that online that I know of is:

%d bloggers like this: