With the proliferation of broadband technologies such as cable modems and DSL, more and more people have systems "permanently" connected to the Internet. While many Internet Service Providers forbid users from providing services such as HTTP or FTP from their broadband-connected machines, eventually, you may find yourself away from home, needing access to your personal computer. But, unless you're one of the lucky few who received a static IP address from your ISP, your home machine may not be that easy to find. That is, if you are not using dynamic DNS.
Table 1. Dynamic DNS Providers
| URL | Hostname | Hostname in your own domain |
| www.ez-ip.net | $25/year | Not available |
| www.dyndns.org | Free | $30 donation |
| www.ods.org | Free | Free |
| www.dyn.ca | Free | $40 Canadian/year |
| www.tzo.com | $25/year | $59.95 |
| www.easydns.com | $35/year | $35/year |
| www.dyns.cx | Free | 15 EUR/year |
| www.hn.org | Free | Free |
| www.zoneedit.com | N/A | Free |
| www.dyndsl.com | Free | Not Available |
Once you have picked a provider and registered for your service you need to let the provider's nameservers know whenever your IP address changes. Most providers provide a web interface to your account where you can manually enter your IP address every time it changes. If that seems a little tedious some services let you set your web browser's start page to a URL that will automatically update your account with your new IP address every time you start your browser. While this automates the process, it doesn't help much if you don't start your browser or if your IP address changes after starting your browser.
What is needed is a way to automatically detect when your IP address changes and notifiy your dynamic DNS provider. Your service provider may point you to dynamic DNS clients that will work with their services and a quick search on Freshmeat.net for dynamic and DNS turns up dozens of applications that will do the job.
One of the best dynamic DNS clients available is ez-ipupdate (http://www.gusnet.cx/proj/ez-ipupdate). ez-ipupdate is a small C program that currently supports twelve dynamic DNS service providers. It can be run from the command line for manual updates or in daemon mode to monitor your IP address and notify your provider only when your IP address changes. (Dynamic DNS service providers like this as it cuts down on their network utilization and system resources.)
ez-ipupdate is available as source code or as an RPM. Once you've built and installed the package you will need to update /etc/ez-ipupdate.conf to specify which dynamic DNS service you're using and provide some other information on how you want ez-ipupdate to run.
Listing 1. /etc/ez-ipupdate.conf
01 #!/usr/local/bin/ez-ipupdate -c
02 #
03 # example config file for ez-ipupdate
04 #
05 # this file is actually executable!
06 #
07
08 service-type=dyndns
09 user=jbodnar:password
10 host=jbodnar.dyndns.org
11 interface=eth0
12 max-interval=2073600
13
14 # Please create this file and ensure that the user
15 # that ez-ipupdate is running as has write
16 # permissions to it then uncomment this line, if
17 # you don't your dyndns account will probably get
18 # banned. If you run ez-ipupdate as root (bad
19 # idea, use "run-as-user") then you can just
20 # uncomment this line.
21 #cache-file=/etc/ez-ipupdate.cache.eth1
22
23 # For the mean time we'll just use a cache file in
24 # the temp directory
25 cache-file=/tmp/ez-ipupdate.cache
26
27 # Uncomment this once you have everything working
28 # how you want and you are ready to have
29 # ez-ipupdate running in the background all the
30 # time. To stop it you can use "killall -QUIT
31 # ez-ipupdate" under Linux.
32 daemon
Looking at Listing 1, the first parameter you need to change is on line 8. service-type specifies the dynamic DNS service provider you are using. The accepted values are ezip, pgpow, justlinux, dhs, dyndns, dyndns-static, ods, tzo, gnudip, easydns, dyns, hn and zoneedit. Many of the providers use different protocols for updating their services. By specifying service-type, ez-ipupdate will pick the appropriate protocol for you.
The next parameter you're interested in is on line 9. This is where you specify the username and password you used to create your account with the service provider. Line 10 lists the hostname you have chosen for your dynamic IP address. Line 11 is especially important for people who are running gateway machines with multiple network interface cards. You need to enter the interface your machine uses to connect to the Internet (otherwise you may map your hostname to an IP address on your internal network which most likely is not what you want to do). Line 12 lists the maximum number of seconds ez-ipupdate will wait before it automatically updates your service. You should set this pretty high so you don't upset your service provider with frequent, unnecessary updates.
Line 25 lets you specify a cache file where ez-ipupdate will keep a record of when your IP address last changed and what it changed to. It uses this to make sure your service is only updated when your IP address changes or after the maximum interval between updates has expired.
Finally, line 32 tells ez-ipupdate to run in daemon mode, meaning it will remain an active process, monitoring your IP address and updating your service as necessary. Without this, ez-ipupdate would run once, update if needed and then exit.
After configuring ez-ipupdate you will need to configure your system to start ez-ipupdate at boot time. This can be as simple as adding /usr/local/bin/ez-ipupdate -c /etc/ez-ipupdate.conf to rc.local or creating a separate script for it in /etc/rc.d/initd and using chkconfig or creating symlinks to make sure it starts during the appropriate run levels.
Once you've finished editing your config file and creating your start script you can run /usr/local/bin/ez-ipupdate -c /etc/ez-ipupdate.conf from the command line to start the daemon and update your hostname with your current IP address.
In order to use DNS update requests you must be running BIND 8 or 9 (or another DNS server that supports update requests). To configure BIND to allow dynamic updates you must add the allow-update statement to the zone section for the domain you wish to have dynamic hostnames in /etc/named.conf (see Listing 2). (It is recommended that you do not use a zone that contains static DNS information as you could accidentally delete or modify important information about the zone or hosts within it.)
dnskeygen that can be used to create the key. BIND 9 includes a similar program called dnssec-keygen that uses a different syntax.
To create a key with BIND 8's dnskeygen you would execute the following command:
# dnskeygen -H 128 -h -n home-dns.shakabuku.org.In the command above, -H specifies the key should be generated using the HMAC-MD5 algorithm and is followed by the size of the key and -h specifies that the key is a HOST key. (There are also ZONE keys for zone transfers and USER keys for email.) -n is followed by the name of the key. You should try to name the key to reflect the host and nameserver that will be sharing the key.
To create a key with BIND 9's dnssec-keygen you would execute the following command:
# dnssec-keygen -a HMAC-MD5 -b 128 -n HOST home-dns.shakabuku.org.When using
dnssec-keygen, -a specifies the algorithm, -b the key size and -n the key type. The final argument is the name of the key.
Both dnskeygen and dnssec-keygen create two files containing the key: K<key name>.+<algorithm number>.+<key fingerprint>.key and K<key name>.+<algorithm number>.+<key fingerprint>.private. In the examples above the files created would be similar to the following:
Khome-dns.shakabuku.org.+157+48378.key Khome-dns.shakabuku.org.+157+48378.privateBoth of these files should be readable only by root and should be kept with other DNS-related files (in
/var/named perhaps). Once you have created your key, you need to securely transfer these two files to the nameserver machine (or host depending on which machine you created the keys on). SSH is an excellent way to get the key files from one machine to another.
On the nameserver you need to create a file that defines keys for BIND (see Listing 3). (Keys can be defined in /etc/named.conf but since many distributions install this file world-readable by default it is often better to put your keys in a separate file.)
Listing 3.
Once your keys are in place you need to make a couple of changes to /etc/dns.keys.conf
01 key home-dns.shakabuku.org. {
02 algorithm hmac-md5;
03 secret "1Vqo67OVy6f7I2xbyR903p==";
04 };
In Listing 3, line 1 defines the key name. Line 2 specifies the algorithm used to create the key. Line 3 is the key itself. You can copy the key from either the .key or .private files you created earlier. In your .key file, the key is the last field of the only line in the file. The .private file contains three records of the format "name: value". The key is the value of the last record.
/etc/named.conf on the nameserver (see Listing 4).