Thursday, February 26, 2026

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

On Thu, Feb 26, 2026 at 09:37:03AM +0000, 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
>

I do it the other way round: use nsd (behind unbound, but that's not
relevant here) to match IPs and hostnames, and then use hostnames
instead of IPs in dhcpd.conf. E.g.


zone file:

foo.example.com 192.168.77.2


dhcpd.conf:

host foo {
hardware ethernet aa:bb:cc:dd:ee:ff;
fixed-address foo.example.com;
}

Changes to the zone file require restarting dhcpd, so that they
propagate.

Big caveat: dhcpd start becomes dependent on DNS, obviously. If DNS
fails to start, or isn't responding for some reason (especially relevant
if it is running on a different machine), dhcpd will fail to start, and
things might get messy. The trade-off between sturdiness and DNS/DHCP
maintenance overhead works for me, but might not work for others.


--

No comments:

Post a Comment