Dnsmaq and hostid option

I recently switched from odhcpd to dnsmasq even for dhcpv6 and ra.

After the switch dnsmasq would not start but crash immediately.

It turned out the reason were some hostids that I set to ensure static assignment.
I used 64bit/16hex hostid and this worked perfectly well on odhcpd. The value was used as the "interface id" of the addresses.

However dnsmasq seems to work differently:
For some hostid it worked but took only the second half of hostid.
For some hostids it generated some bad addresses and caused crash.

For instance 7ba22d5143a10b64 is ok, but only uses lower values int generates [::43a1:b64] suffix. However b0552d4cd6f490ab results internally in [::ffffffffffffd6f4:ffffffffffff90ab]somehow, and crashes dnsmasq.

After I shortened my hostid to 32bits it works all right.

Any ideas whether this is intended behavior or a bug? Am I doing something terribly wrong?

Can you show us the portion of the configuration that you're referring to?

In /etc/config/dhcp

you can have:

config host                                                                       
        option name 'my-hostname'   
        option dns '1'                           
        list mac 'XX:XX:XX:XX:XX:XX'             
        option ip '10.0.0.42'                                                      
        option hostid 'b0552d4c'          # this is ok
        #option hostid 'b0552d4cd6f490ab' # this is not ok

dnsmasq takes these and then produces /var/etc/dnsmasq.conf.cfg01411c

when I use 64bit hostid then there is entry like:

dhcp-host=XX:XX:XX:XX:XX:XX,10.0.0.42,[::ffffffffffffd6f4:ffffffffffff90ab],my-hostname

when I use 32bit hostid then there is entry like:

dhcp-host=XX:XX:XX:XX:XX:XX,10.0.0.42,[::b055:2d4c],my-hostname

Did you checked dnsmasq config documentation? This looks totally wired.

hostid is mentioned in:

both seems to be related to odhcpd however.

I do not think I have seen it in dnsmasq doc, so I would expect it do do nothing or do the same as odhcpd.

The man page seams to assume only full addresses are supported.
So yes something is still odd with the UCI translation.

1 Like

Upstream doc: https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

1 Like

btw I use OpenWrt 23.05.5 maybe it's fixed in latter version?

Can't you just live for now with the 32bit identifier :sweat_smile:

1 Like

I think I can :smiley: .
Also for most of my device I enter the locally generated forever address into DNS, so even if dhcpv6 broke it should work for me.

Most devices generate permanent ULA address either from MAC or duid.

Do know by any chance how with the default OpenWrt config it is possible to get PTR for slaac addresses? I think odhcpd does something with the Mac address on the IP neighbor table...
But I disabled odhcpd long ago in favour for dnsmasq full

Did you checked the GitHub issues and could you open a new one with your compiled findings?

I am afraid you need create the ptr records manually for unbound via /etc/unbound/unbound_srv.conf.

For dnsmasq you can just add host record (manually).

config domain                      
        option name 'my-host.my-domain'             
        option ip 'slaac address here'

It will get you both forward and reverse record.

I have no completely automatic solution.

1 Like

I think by default you won't even get forward (AAAA) records on slaac, only on dhcp.

1 Like

I don't know. Maybe in latter versions, but I do not think I observe such a thing on my machine.

Now I recall I have also router with 24.10.1 which should be quite recent. I do not think slaac host resolution work there in any way. At all.

I recall I had to manually add records.

But I think it would be pretty cool if odhcpd could leverage neighbor table in such a way.
In theory it would work.

What however could work is mDNS. You can for instance enable it in your local desktop/laptop resolver like systemd-resolved/nsswitch then you can resolve hostname.local but it still won't do reverse lookup. I always had to do avahi-resolve -a <address here> to do revers lookup.

Yeah but I dislike mdns.
For now I also just collect all addresses of a host as good as possible and add names for them.