Thursday, February 26, 2026

Re: How do you keep dhcpd and nsd/unbound in sync?

On 2/26/26 04:37, Martin wrote:
> Currently we run Unbound without NSD for our local net where
> Unbound has a local file with IPs and PTRs for the LAN. We
> also use dhcpd to assign fixed IPs based on the MAC.
>
> So far all is done manually. Is there some way to automatically
> add hosts and hostnames to Unbound when a lease is granted from
> dhcpd or some other way?
>
> Kind regards
>

MANY years ago, someone named Michael Stella wrote a script to
populate DJBDNS files from dhcpd. I found it fairly easy to
convert to NSD. It is no longer on his website, but it's in
the internet archive at:

https://web.archive.org/web/20160310223857/http://www.thismetalsky.org/files/dhcp_dns/dhcp_dns/

I've been using it in-house for well over 20 years now.
Very slick, when I bring a new machine on-line, by the time
I care about its DNS resolution, it has been populated and
answering accordingly.

Issues:
* It should use nsd-control to reload the zone files, but it
doesn't...so it runs as root, which is not good.
* Doesn't populate reverse DNS (should be an easy addition for
some cases)
* In-house, I have different subnets for wifi and wired. If a
machine moves from wired to wifi, the DNS does not change in a
timely manner (should be fixable)
* It doesn't handle multiple dhcpd servers. It appears our
dhcpd with synchronization doesn't actually sync the
dhcpd.leases files between dhcpd nodes (or I'm doing it wrong).

Nick.

No comments:

Post a Comment