::::: : the wood : davidrobins.net

Auto-importing DHCP hosts into local DNS

News, Technical, Photography ·Saturday December 27, 2008 @ 23:33 EST (link)

20081224: Went to sleep around 0700, got up 1330; two hour power outage, 1345 to 1545; played Carcassonne, power came back towards the end. Power bounced again at 1605.


20081225: I debated titling this entry Merry Christmas to some, bah humbug to PSE, but time truly does diminish wounds. The snow was far heavier than normal for this area, and I'm sure the people that fixed the various outages weren't involved in the design decisions that caused them (I'm sure they had mixed emotions about the overtime vs. being called out on Christmas Day). We had a short outage at 0306-0307, and a few more sub-minute outages in the early am. NTP was having trouble on the MythTV box (and our ancient desktop), possibly because it was so far off from the hardware clock (hwclock). Updated system time to be approximate, and then /etc/init.d/ntp-client worked, and I ran hwclock --systohc --local to update the hardware clock (and made sure it was being set on shutdown, via /etc/conf.d/clock). Then the big one came: the power went out from 0740 to 1205. Really? Yep. Christmas morning without power. Laptop didn’t resume from hibernation, had to do a full boot, and I even let the disk check run.

I set the various local machines to pass in a DHCP hostname (via either /etc/conf.d/net for the old baselayout-1 machine, /etc/dhcp/dhcpcd.conf for baselayout-2 machines), then setup tinydns (part of the djbdns toolset) on the server, using this Gentoo guide; tinydns is listening on 127.0.0.1, and dnscache redirects to it for .internal addresses. We're now powered by djbdns (the author asks people to write that so it shows up on searches). I wrote dhcp_tinydns, a (perl) program inspired by this one to update the DNS data for DHCP, using Linux::Inotify2 to watch dhcpd.leases, Text::DHCPLeases to parse the leases file, and a few DateTime modules to parse the lease end date and output it in TAI64 format for the tinydns data file. Now I can SSH to or ping machines by name rather than IP address, which is handy.

Snow's melting; we should be able to get out tomorrow. Called my family, talked to my Dad for a while; Mom and Emily were out taking Grandma to other relatives; talked to 3 of 4 sisters and a brother-in-law.


20081226: Tweaked dhcp_tinydns to log using Sys::Syslog (with tweaks to syslog-ng.conf to log to a new location), and daemonize using App::Daemon, and wrote a Gentoo init script for it.

Still couldn't get the car out today: snow, ice (slick from kids sledding on it), a front-wheel drive car, and a steep uphill street all worked against me.

20081227: Still can't get out, although the white crap is beginning to melt. Added internal reverse DNS support: needed to create /var/dnscachex/root/servers/0.0.10.in-addr.arpa containing 127.0.0.1, the internal address of the tinydns server, same as for the internal file in the same directory. For tinydns, I needed to add a nameserver line for the 10.0.0. prefix: .0.0.10.in-addr.arpa:127.0.0.1:a:259200. Now dig -x works as expected.

Books finished: Technical Analysis, Bioinformatics, Japanese Candlestick Charting Techniques, The Candlestick Course.

DVDs finished: A Christmas Story.