Dynamic DNS

From IthrynWiki

Jump to: navigation, search

This is adapted from Brad’s notes in /etc/bind/README-dyndns

Note: the commands dnssec-keygen and nsupdate are part of the BIND9 distribution (try the client package for UNIX-like systems; also available for Windows if you look hard enough).

Client Side

On my local server I created a key via:

$ dnssec-keygen -a HMAC-MD5 -b 512 \
    -n HOST bkn.dunedain.ithryn.net

This will create two key files in the current directory. Mine were named </pre> Kbkn.dunedain.ithryn.net.+157+18967.key Kbkn.dunedain.ithryn.net.+157+18967.private </pre>

Server Side

On the server I created a file /etc/bind/bkn.key, containing:

key bkn.dunedain.ithryn.net. {
    algorithm HMAC-MD5;
    secret "the_key_data";
};

Then I included it in /etc/bind/named.conf, and added my key in the 'allow-update' section of the zone dunedain.ithryn.net.

Reload the DNS config via:

$ sudo /etc/init.d/bind9 reload

and check /var/log/syslog to make sure that it reads the new info without any troubles.

Back to the Client Side

Using nsupdate I was able to update my record on ithryn.

$ sudo nsupdate -k Kbkn.dunedain.ithryn.net.+157+18967.key
update delete bkn.dunedain.ithryn.net
update add bkn.dunedain.ithryn.net 3600 A 151.203.235.115
send

On the server you might want to tail /var/log/syslog to make sure that the records get updated.

I wrote a perl script that will run as a daemon, and monitor the IP, if the IP changes it will run nsupdate. You will need to tweak a few things in the script at the bottom for the get_ip() function, and the nsupdate() function. The script lives in my home directory on Ithryn (/home/brad/nsupdate_daemon.pl). NOTE: This script has since been updated by Brian: nsupdated.tgz.

Personal tools