Saturday, May 17, 2008

DNS updates with tinydns

I administer a small network (~30 hosts), and I've set up a router running DJ Bernstien's tinydns and a DHCP server. I wanted to have tinydns update itself each time a new host connects to the network and announces its host name to the DHCP server. Fortunately, Michael Stella had written a handy Perl script to do just this, called I had this set up, and everything seemed to work, except that new DHCP clients only appear in the DNS system after a day or so. Strange.

It turned out the problem lay in the fact that I'm using the dnscache part of tinydns in addition to the regular dns server. The usual approach with most of DJ Bernstien's programs is to call the "svc" program with a "-h", which ends up restarting it to reload configuration files. The script periodically checks the DHCP leases file to detect changes. These changes are then written to the tinydns configuration files and tinydns is restarted. This is done using a Makefile in /etc/tinydns/root, but the Makefile does not restart the dnscache. The dnscache updates itself once a day or so, hence the delay.

So I modified the Makefile to add this line after the tinydns restart line:

/usr/local/bin/svc -h /etc/dnscache

Mystery solved...