1

I have recently converted one of my main Linux servers into my router as well, and made my old router simply a switch and an access point. My one issue is that I am unable to automatically determine hostnames on my local network and add them to the DNS cache. If I need to switch back to DNSMasq for this, I'm willing to, it's just that I wound up with BIND in my research. From what I've found, nmblookup is one of the best things I've found so far, but I'd really rather not install samba and start nmbd on all of the devices in my house just to get hostname resolution. I know that there is some way to do this, as my previous router was able to do this just fine for all hosts. Any ideas?

2

ISC dhcpd is capable of doing dynamic DNS updates in combination with BIND, but not without some configuration. The full information can be found in the dhcpd.conf man page; essentially, you should do something along the following lines:

  • Run ddns-confgen. This generates some config blocks that you need to add to your named.conf file, along with instructions. Follow them. It also talks about nsupdate. This isn't necessary since you'll be using dhcpd, but you can use nsupdate to verify that your bind configuration was done correctly.
  • Copy the key block to your dhcpd.conf as well.
  • In your dhcpd.conf, also add the following config blocks:

    zone example.com. {
        primary 127.0.0.1;
        key ddns-key;
    }
    
    zone 0.0.10.in-addr.arpa. {
        primary 127.0.0.1;
        key ddns-key;
    }
    

    Obviously, you should replace the zone names with the zones you're trying to update.

Once you've done that, it should work.

Disclaimer: I've only ever used the bind side of the above myself, never the dhcp bit.

Also note that the TSIG keys aren't strictly necessary; it is possible to allow IP-based dynamic DNS updates, in which case it will work out of the box from the DHCP side of things. However, for security reasons this isn't recommended.

1

Who assigns the hostname => IP address mapping?

DNSMasq works because it is both a DHCP server as well as a DNS server. However, when you have two systems - BIND for DNS and something else for DHCP, then you might need to jump through hoops. I am not sure how to do this (would have actually commented on your question, if had enough rep) however looking at DHCP hooks might be useful. One way could be to setup a dynamic DNS zone on BIND and have a script (hooked into the DHCP) do an nsupdate to BIND.

Or, simply move to DNSMasq :)

  • So how could I get the hostname at all? I couldn't figure out how to attain a hostname with dhcpd and BIND at all... DNSMasq sounds good, but its DHCP server gave me a lot of trouble. Like, I couldn't connect to it. Edit: DNSMasq's DHCP seems to be working fine now... that's nice. – John Leuenhagen Aug 23 '16 at 2:08
  • With DNSMasq, I actually provide a set of MAC Address => hostname mappings by putting in lines like the following in the /etc/dnsmasq.conf file: dhcp-host=<MAC Address>,<IPv4 Address>,<hostname>,[<IPv6 suffix>] – SACHIN GARG Aug 23 '16 at 2:49
1

You need to either maintain hosts files on your machines or run an authoritative DNS server on your network.

Hosts files are the easiest, but of course you either have to change them every time you add a host (on every machine) or maintain them with something like NIS. If you rarely add or remove hosts, this is probably the right way to go. You'll need static IPs, of course. Hosts files work with Windows as well (although NIS does not).

If you want to set up an authoritative DNS server, it's not too difficult to do. There's several out there, and BIND is the heavy duty option. It's not horribly complicated, but prepare yourself for a bit of a learning curve. There's a ton of howtos around the net. One common hangup: every time you make a change to a zone file, increment your version number - otherwise BIND might not load your changes.

BIND works well with ISC's DHCP server for dynamic dns updates, so if you run DHCP you can tell your machines to register their IPs with BIND. The man page for dhcpd.conf have information on this. This is what I do at home, and while it takes a bit of learning to set it all up, it works pretty much flawlessly once it's running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.