DNSmasq not resolving local DNS names for static leases until first DHCP request

Started by cinergi, May 26, 2025, 07:26:45 PM

Previous topic - Next topic
Hello,

Like others, I've switched from ISC to DNSmasq DHCP.  It seems to be working fine overall, except I've noticed that local DNS names for static DHCP leases defined in DNSmasq > Hosts are not resolved until the first DHCP request/offer exchange.  Is this normal?

Thanks!

It depends, but essentially yes.

A hostname will be registered dynamically when a lease is issued. (Combining the hostname + dhcp-range domain)

Before that, it depends on the contents of "/var/etc/dnsmasq-hosts", which gets populated automatically when you do a static reservation. If the host is in there with IP address, hostname and domain, you will be able to resolve it /before/ the lease has been registered.

The domain is mandatory if you do query forwarding from Unbound to Dnsmasq.

In version 25.1.7_4 this should work as expected.
Hardware:
DEC740

It depends. First, on OpnSense version: Use 25.1.7_4, the latest, because earlier versions had problems with this.

With 25.1.7_4, a DHCPv4 static reservation should work if you have: a.) a hostname b.) a MAC and / or client ID and c.) an IPv4 address.
For DHCPv6, you must have an IPv6 address that does not start with "::", because that signifies an address that still needs the (dynamic) interface prefix to get registered. In this case, you need a DHCPv6 registration in order to have the hostname registered.

You can verify if your static reservation gets handled as "static" for DNS purposes by looking at /var/etc/dnsmasq-hosts, which hold the static reservations.

Ah, Cedrik beat me to it... ;-)
Intel N100, 4* I226-V, 2* 82559, 16 GByte, 500 GByte NVME, ZTE F6005

1100 down / 800 up, Bufferbloat A+

Well I already forgot about the IPv6 edgecase so thank you anyway :)
Too many edge cases to keep track of lol.

But we're getting quite close to being finished with it now.
Hardware:
DEC740

;-)

I still have some edge cases left... see: https://forum.opnsense.org/index.php?msg=238632.

I was just about to tell you when Ad exploded, but never mind.
Intel N100, 4* I226-V, 2* 82559, 16 GByte, 500 GByte NVME, ZTE F6005

1100 down / 800 up, Bufferbloat A+

Quote from: Monviech (Cedrik) on May 26, 2025, 08:07:21 PMThe domain is mandatory if you do query forwarding from Unbound to Dnsmasq.

In version 25.1.7_4 this should work as expected.

OK, this is the part I was missing: when I created my static entries in DNSmasq > Hosts, I did not include the domain.  Now the static entries all resolve fine even without an initial DHCP exchange.

Thanks!

I noticed a new potential issue: DNSmasq will randomly stop resolving local hostnames, returning NXDOMAIN.  It sometimes resumes working after a while, otherwise restarting it works too.  Is this a known issue?  I recall reading similar anecdotal reports recently on the forum.