Block randomized MAC address using Dnsmasq, possible?

Started by OrlyP, September 28, 2025, 03:09:10 PM

Previous topic - Next topic
Without delving into the "why", I need help making this possible.

I use Dnsmasq as my DHCP server and I'm playing around with the following config but Dnsmasq errors out at line 2 to 5. I don't know if it's a syntax error or if dhcp-host doesn't allow masks.

dhcp-range=set:EARTH,192.168.35.51,192.168.35.200,255.255.255.0,24h
dhcp-host=*2:*:*:*:*:*,set:random_mac
dhcp-host=*6:*:*:*:*:*,set:random_mac
dhcp-host=*a:*:*:*:*:*,set:random_mac
dhcp-host=*e:*:*:*:*:*,set:random_mac
dhcp-ignore=tag:EARTH,tag:random_mac

Honestly, I don't know what I'm doing. lol

Any helping hand will be very much appreciated.

If you dont know what you are doing read the dhcp-host directive in the man page, it explains everything:

https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html
Hardware:
DEC740

Quote from: Monviech (Cedrik) on September 28, 2025, 03:56:32 PMIf you dont know what you are doing read the dhcp-host directive in the man page, it explains everything:

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

Ah well... so evidently, wildcard masks aren't supported.

Thank you. It was already late last night and didn't think better to look at the docs.

I'm also looking for a way to ignore the random MAC address.
I found something interesting here.

https://community.ui.com/questions/Block-Random-MAC-Addresses/8fbf5f69-b965-4c05-bd2f-aa62548dc35c#answer/e896d1f6-e375-4663-ae15-3c1470c83295

dhcp-host=02:*:*:*:*:*,ignore
dhcp-host=12:*:*:*:*:*,ignore
dhcp-host=22:*:*:*:*:*,ignore
dhcp-host=32:*:*:*:*:*,ignore
dhcp-host=42:*:*:*:*:*,ignore
dhcp-host=52:*:*:*:*:*,ignore
dhcp-host=62:*:*:*:*:*,ignore
dhcp-host=72:*:*:*:*:*,ignore
dhcp-host=82:*:*:*:*:*,ignore
dhcp-host=92:*:*:*:*:*,ignore
dhcp-host=A2:*:*:*:*:*,ignore
dhcp-host=B2:*:*:*:*:*,ignore
dhcp-host=C2:*:*:*:*:*,ignore
dhcp-host=D2:*:*:*:*:*,ignore
dhcp-host=E2:*:*:*:*:*,ignore
dhcp-host=F2:*:*:*:*:*,ignore
dhcp-host=06:*:*:*:*:*,ignore
dhcp-host=16:*:*:*:*:*,ignore
dhcp-host=26:*:*:*:*:*,ignore
dhcp-host=36:*:*:*:*:*,ignore
dhcp-host=46:*:*:*:*:*,ignore
dhcp-host=56:*:*:*:*:*,ignore
dhcp-host=66:*:*:*:*:*,ignore
dhcp-host=76:*:*:*:*:*,ignore
dhcp-host=86:*:*:*:*:*,ignore
dhcp-host=96:*:*:*:*:*,ignore
dhcp-host=A6:*:*:*:*:*,ignore
dhcp-host=B6:*:*:*:*:*,ignore
dhcp-host=C6:*:*:*:*:*,ignore
dhcp-host=D6:*:*:*:*:*,ignore
dhcp-host=E6:*:*:*:*:*,ignore
dhcp-host=F6:*:*:*:*:*,ignore
dhcp-host=0A:*:*:*:*:*,ignore
dhcp-host=1A:*:*:*:*:*,ignore
dhcp-host=2A:*:*:*:*:*,ignore
dhcp-host=3A:*:*:*:*:*,ignore
dhcp-host=4A:*:*:*:*:*,ignore
dhcp-host=5A:*:*:*:*:*,ignore
dhcp-host=6A:*:*:*:*:*,ignore
dhcp-host=7A:*:*:*:*:*,ignore
dhcp-host=8A:*:*:*:*:*,ignore
dhcp-host=9A:*:*:*:*:*,ignore
dhcp-host=AA:*:*:*:*:*,ignore
dhcp-host=BA:*:*:*:*:*,ignore
dhcp-host=CA:*:*:*:*:*,ignore
dhcp-host=DA:*:*:*:*:*,ignore
dhcp-host=EA:*:*:*:*:*,ignore
dhcp-host=FA:*:*:*:*:*,ignore
dhcp-host=0E:*:*:*:*:*,ignore
dhcp-host=1E:*:*:*:*:*,ignore
dhcp-host=2E:*:*:*:*:*,ignore
dhcp-host=3E:*:*:*:*:*,ignore
dhcp-host=4E:*:*:*:*:*,ignore
dhcp-host=5E:*:*:*:*:*,ignore
dhcp-host=6E:*:*:*:*:*,ignore
dhcp-host=7E:*:*:*:*:*,ignore
dhcp-host=8E:*:*:*:*:*,ignore
dhcp-host=9E:*:*:*:*:*,ignore
dhcp-host=AE:*:*:*:*:*,ignore
dhcp-host=BE:*:*:*:*:*,ignore
dhcp-host=CE:*:*:*:*:*,ignore
dhcp-host=DE:*:*:*:*:*,ignore
dhcp-host=EE:*:*:*:*:*,ignore
dhcp-host=FE:*:*:*:*:*,ignore

Hopefully I can limit it to one interface.

The manual says:
Ethernet addresses (but not client-ids) may have wildcard bytes, so for example --dhcp-host=00:20:e0:3b:13:*,ignore will cause dnsmasq to ignore the given range of hardware addresses. Note that the "*" will need to be escaped or quoted on a command line, but not in the configuration file.