OPNsense Forum

English Forums => 25.1, 25.4 Production Series => Topic started by: cinergi on May 26, 2025, 07:26:45 PM

Title: DNSmasq not resolving local DNS names for static leases until first DHCP request
Post by: cinergi on May 26, 2025, 07:26:45 PM
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!
Title: Re: DNSmasq not resolving local DNS names for static leases until first DHCP request
Post by: Monviech (Cedrik) on May 26, 2025, 08:07:21 PM
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.
Title: Re: DNSmasq not resolving local DNS names for static leases until first DHCP request
Post by: meyergru on May 26, 2025, 08:09:51 PM
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... ;-)
Title: Re: DNSmasq not resolving local DNS names for static leases until first DHCP request
Post by: Monviech (Cedrik) on May 26, 2025, 08:14:23 PM
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.
Title: Re: DNSmasq not resolving local DNS names for static leases until first DHCP request
Post by: meyergru on May 26, 2025, 08:20:51 PM
;-)

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.
Title: Re: DNSmasq not resolving local DNS names for static leases until first DHCP request
Post by: cinergi on May 26, 2025, 08:25:13 PM
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!
Title: Re: DNSmasq not resolving local DNS names for static leases until first DHCP request
Post by: cinergi on May 27, 2025, 04:08:33 AM
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.