Dynamic DNS

It's impractical to run your own DNS servers if your IP address is dynamic changes. Even if you wanted to pay for a static address, you're probably better off taking advantage of someone else's infrastructure if you can. Many top tier hosting companies are giving away DNS services for free anyway, so pick a provider and install a client.

The Service Provider
As with many things, there are two parts; the Service Provider and the Client. Here's a good list of them. I've used editDNS and subsequently ZoneEdit and also NameCheap, the latter being now free.


The Client

For Ubuntu, the most used client for ddns seems to be ddclient.  The instructions are at  http://help.ubuntu.com/community/DynamicDNS or, after installing you can enter ddclient -help for the most up-to-date info on the client

sudo apt-get install ddclient

You may elect to change the config file yourself. Here's a config for NameCheap

sudo vim /etc/ddclient.conf

use=if, if=eth0


By default, ddclient runs as a daemon (on ubuntu, at least) but you may want to check your defaults to make sure

sudo less /etc/default/ddclient

Advanced Client Useage

An advanced use case is one where you have multiple address to maintain, such as when combining openvpn and dyndns. Below is a an example configuration that accomplishes this by retrieving the external IP using a web service, and the internal IP from the local eth0.

sudo vim /etc/ddclient.conf

use=web, web=checkip.dyndns.com/, web-skip='IP Address', server=dynamic.zoneedit.com, login=YourLogin, password='YourPassword' external.gattis.org
use=if, if=eth0, ssl=yes, server=dynamic.zoneedit.com, login=YourLogin, password='YourPassword' internal.gattis.org

The placing of commas are important. When using two host updates, there seems to be no output so to debug:

sudo ddclient -daemon=0 -debug -verbose -noquiet


 For some providers, such as zoneedit, you can use a simple curl script, or even a one-liner in cron.

curl -s -u user_name:password https://dynamic.zoneedit.com/auth/dynamic.html?host=host.domain.org