I followed the guide (https://docs.opnsense.org/manual/dnsmasq.html#dhcpv4-with-dns-registration) on how to set dnsmasq correctly to resolve local addresses ( dns unbound -->> dnsmasq ).
However I encounter this problem:
if I set dhcp reservation, in dnsmasq, leaving the host field empty but filling in the domain field:
(https://i.postimg.cc/fLKYNZFS/1.png)
I can't resolve the addresses correctly, (nslookup 192.168.34.15) :
(https://i.postimg.cc/kGY82s7n/2.png)
The name "OTGW" is obtained from the device.
if I set dhcp reservation, in dnsmasq, filling either the host field and the domain field:
(https://i.postimg.cc/HnkXWRDZ/3.png)
in this case everything is as I expect
(https://i.postimg.cc/mZm7pLC0/4.png)
the name "otgw" is given by me.
what I would like to achieve is to give custom domain names to the various subnets (VLAN) leaving the hostname field free, so that the device can provide its own hostname, however, providing domain name but not explicitly stating the hostname, something doesn't work to me.
Everything works without giving custom domains and without giving device hostname (using only "internal") or filling in both custom domain and hostname;
Am I wrong in using these settings?
Could someone give me an hint.
Thanks for your attention
You can leave hostname and domain empty in a reservation.
If a dhcp-range has a domain set, and the reservations IP address is inside the range, and the client offers its hostname, it will register as otgw.example.com as soon as it gets a lease.
thanks for your quick reply.
However, what I would like to achieve is to leave only the device name blank, setting a domain with a nomenclature such as vlan.internal (in this case iot.internal).
I know it is complicating life, that there is a way to make the name resolution work, as you suggest.
However, mine is an exercise in style and I can't understand why it can't work in this way.
Perhaps I might lack the cultural basis to understand it.
You leave both empty in the reservation and set the domain in the dhcp range. Each range can have its own domain.
As soon as the DHCP server gives out a lease, the DNS name will be registered.
already done, and it's not working as i intended.
(https://i.postimg.cc/MGTK3wwp/5.png)
I think that putting it in the range is still valid for leases that are assigned via dhcp and not via host reservation (what i'm triyng to achieve).
The Client has to get a lease issued before its name can be resolved.
A reservation just writes it statically into a separate file so the host can be resolved before DHCP. But it will still get registered the same way additionally.
Its a bit weird to explain it. Sorry if its unclear.
E.g. your DHCP domain is:
iot.internal
192.168.1.1-192.168.1.100
And your dhcp host reservation is
192.168.1.2
fe:fe:fe:fe:fe:fe
- A dynamic DNS entry is created as soon as the client gets a lease:
192.168.1.2 host.iot.internal
reading your answer I realized that the assigned IP was not in the dhcp range (since in other configurations I kept it outside the dhcp range) while in the opnsnese guide/manual it says "The reservation can also be outside the dynamic range, but it is not recommended for simple setups as the dynamic dns registration with dhcp-fqdn will not work correctly."
Modified accordingly (dhcp range include ip in host reservation) , everything works perfectly.
My mistake of superficiality.
Thanks for the support and attention!
We all make mistakes.
Glad you got it resolved.
Its mostly because the domain gets a range assigned.
In a future update you will be able to set the domain to the interface of a range as well, e.g. thats needed for partial IPv6 dns registration.
https://github.com/opnsense/core/pull/8814
Quote from: Monviech (Cedrik) on June 25, 2025, 05:57:25 PMWe all make mistakes.
Glad you got it resolved.
...me then many :)
Quote from: Monviech (Cedrik) on June 25, 2025, 05:57:25 PMWe all make mistakes.
In a future update you will be able to set the domain to the interface of a range as well, e.g. thats needed for partial IPv6 dns registration.
https://github.com/opnsense/core/pull/8814
very cool feature
anyway thanks for the help!