Fool Me Once

For any­one who wants to han­dle dynamic DNS (either in con­junc­tion with DHCPd or not) with Bind and absolutely hates the ver­bosity of nsup­date, here’s a shell script which han­dles the common-cases of adding and removing:

  • Forward/reverse entries
  • CNAMEs

The com­mand line argu­ments are –k (privkey) –a (action) –h (host­name) –i (ipaddr) –c (cname) –d (debu­glevel) (-t ttl)

Usage:
    setns -k privkey -a set -h hostname (-i ipaddr|-c cname) [-d #] [-t ttl]
    setns -k privkey -a unset -h hostname (-i ipaddr|-c cname) [-d #]

You need to be famil­iar enough with Bind9/DNS to have cre­ated a key­pair with dnssec-keygen and added it to your named.conf.

Other ways of sim­pli­fy­ing this are a Tcl/Tk GUI tool and a python script. Neither of which have the dis­tinct advan­tage of my tool: giv­ing me an excuse to do useful/interesting things with bash. Downsides are peren­nial script­ing prob­lems with insuf­fi­cient input val­i­da­tion, it’s not trans­ac­tional (i.e. if the sec­ond half fails it won’t back out the first half), and it requires FQDNs rather than using your search domain.

The script, avail­able under the GPL.

Also, good to see all the progress we’re mak­ing in the ille­gal, immoral, unjust, but mag­i­cally winnable war to let Exxon take upwards of 75% prof­its on all the unex­ploited oil reserves in the Baghdad in the Midwest Cornfields.

3 Responses

  1. James Cape says:

    for­get bind, just use dns­masq instead.

    The name­server is author­i­ta­tive for 4 domains and (cur­rently) 12 VLANs, clients on any one of which could be using DDNS. There are slave name­servers on the other side of the (cur­rently sole, soon to be many) WAN link(s), and we need as close to 5-nines as is practical.

    I appre­ci­ate the pointer, but dns­masq is not even close to being an option for that sit­u­a­tion. :-)

Leave a Reply

*