Linux DNS Client Update Tool

dhcpdomain-name-systemlinux

So I work in a web hosting environment, and I've got a handful of Linux boxen on our primarily Windows-based network. All the machines (both Windows and Linux) on the network have at least two network interfaces, each with its own DNS suffix, so we can separate backup and management traffic from the production web traffic.

The issue is that the backup/management NIC on each machine is using DHCP to get an address and register itself in DNS, while the production NIC is static, and DHCP isn't an option.

The Windows configuration is relatively simple, we set the one DHCP'ed NIC not to register with DNS and just leave DNS registration to the DHCP server. Then we set the static IP'ed NIC to register with DNS, and everything works fine. I want my Linux boxen to do the same thing, and I've got the DHCP NIC figured out, but I'm not finding a whole lot out there about ways to have Linux automatically register a static address in DNS.

Has anyone done anything like that before?

Best Answer

Make sure nsupdate is installed, then use it to register your names. The one problem with nsupdate is that you are going to need to permit non-secure dynamic updates. Unless your platform supports nsupdate-gss, and your linux machines are setup with kerberos to be part of the domain.

I have a script that looks like somewhat like this I use in a couple situations, like dynamic registration of OpenVPN clients. In the real script, the IP and actual hostname comes from the vpn server. If you are using a Debian based distribution it would be pretty easy to tweak this script and place it in /etc/network/if-up.d/.

#/bin/bash

dnssrv="192.168.47.12"   # the dns server that will accept the ddns request.
zone="dyn.example.org"   # the name of the zone
ttl="7200"               # 
hostname=`hostname`      # the name of your local host
ip='192.168.47.193'      # IP of the host

(
 echo "server ${dnssrv}"
 echo "zone ${zone}"
 echo "update delete ${farm}"
 echo "update add ${hostname}.${zone} ${ttl} A ${ip}"
 echo "send"
) | /usr/bin/nsupdate

Another alternative may be to just use DHCP for both interfaces at to setup reservations.