Ubuntu dynamic DNS with DHCP

So it’s “Technical Tuesday” and time to do something I’d been putting off for a while: fix my [no-glossary]network’s[/no-glossary] DNS and DHCP. DNS is a system of swapping between the computer’s IP address (e.g. 192.168.0.51) and its usable name (e.g. elonex.home), and a machine on my network happily provides that service with a fixed set of translations. DHCP is a system whereby when a machine wants to connect to the network it can be told what IP address and network settings it should have. On my small network these have functioned happily for years (hence the unwillingness to change them!). On a small network keeping these two separate is simple enough, but on larger networks you need to have an automatic way of keeping these two in sync. This is dynamic DNS or DDNS. Step one: make sure you have ordinary DNS and DHCP working! Step two: create a key that allows DHCP to automatically update the DNS, edit DNS zone files and DHCP config to use it. Now when a machine switches on it asks the DHCP for its IP address, DHCP provides one and updates the DNS system to reflect that. There are plenty of instructions on the net, best one is at the Ubuntu forums, google for “ubuntu dynamic dns dhcp” But as always it’s never quite that simple… and I was finding that the DHCP wasn’t updating the DNS. Remember - log files are your linux friend. /var/log/syslog reported “elonex dhcpd: Forward map from desktop.home. to 192.168.0.51 FAILED: Has an A record but no DHCID, not mine.” If you get this it’s because there is already a ‘standard’ A record in your DNS zone files and DHCP doesn’t want to upset it, i.e. it looks like:

desktop A 192.168.0.10

and not: desktop A 192.168.0.51 TXT “00d5af4d3a068764f9e7f86068345d98e1”

That extra “TXT” marks the DNS entry as ‘belonging’ to DHCP. Delete your A record and restart DNS. The other little gotcha was that DNS will write a journal file of changes it makes so the location for your DNS zone files (/var/cache/bind/master on my machine) needs to be rw to the user running DNS (bind in my case). So after a bit of head scratching and patience I’ve now got a system where none of the machines on my network need do anything but use DHCP. DDNS gives everyone a proper IP and name and makes sure they can all talk to each other. Some helpful diagnostics: dig @localhost elonex.home - this will tell you if your DNS is working correctly, it should give back the proper IP of the machine called “elonex” host desktop - should tell you the correct IP of the machine called “desktop”