Dnsmasq: set tag using only MAC address?

According to the dnsmasq docs, I think this should work to tag to a device using only the MAC address:

dhcp-host=00:A1:59:8B:3D:60,set:adguard

When I add that to the config in /var/etc (and then kill -HUP the process), my device doesn't seem to get the options in the tag (a custom DNS server).

However, when I include the hostname in the config, then it works (the device gets the custom DNS server defined in the tag):

dhcp-host=00:A1:59:8B:3D:60,set:adguard,TV

Is OpenWRT possibly using an old or limited build of dnsmasq that could explain why this doesn't work with only the MAC address?

P.S. uci also seems to need the name added to it's config, otherwise it won't populate the dhcp-host setting in /var/etc/dnsmasq.conf

dhcp.@host[2]=host
dhcp.@host[2].name='TV'
dhcp.@host[2].mac='00:A1:59:8B:3D:60'
dhcp.@host[2].tag='adguard'

Sorry but that's not how to work on OpenWrt.

1 Like

What's the issue then for you?

1 Like

Did some more testing and it turns out that it's possible to make this work with only the MAC address and tag, but only if manually editing /etc/dnsmasq.conf.

The kill -HUP method of getting dnsmasq to reload its config doesn't work, because dnsmasq doesn't re-read the full config when handling that signal.

So to me there's a bug in the dnsmasq init script, where it requires a name in the uci config, even though dnsmasq doesn't need one.

Looking at the init script code, it appears that it reads the name, ip, and hostid, then exits if those are empty. I think this is a bug because dnsmasq does accept configs with only a MAC address.

If you think it's a bug in OpenWrt then compile your issue and your expectations and your tested config and open an issue at OpenWrt GitHub project...

Already done: https://github.com/openwrt/openwrt/issues/22051

2 Likes