[Dnsmasq-discuss] Define default dhcp-range when multiple one exist

Jesus M Diaz jesusm.diazperez at gmail.com
Sat May 15 11:22:45 UTC 2021


Hello,

I am trying to set different ranges in my dnsmasq configuration, to be used
based on tags. I have a series of dhcp-host entries, matching by
mac-address, and setting host-name and tag in most cases, and static lease
in others:

dhcp-host=set:iot,a1:b1:c1:d1:e1:f1,hostname1
> ...
> dhcp-host=set:mobile,a2:b2:c2:d2:e2:f2,hostname2
> ...
> dhcp-host=set:entertainment,a3:b3:c3:d3:e3:f3,hostname3
> ...
> dhcp-host=a4:b4:c4:d4:e4:f4,ip-add4,hostname4,lease-time


I have 4 ranges, one for each 'tag', and one more for the unknown devices.

dhcp-range=192.168.0.251,192.168.0.254,5m
> dhcp-range=tag:mobile,192.168.0.201,192.168.0.250,30m
> dhcp-range=tag:entertainment,192.168.0.30,192.168.0.49,24h
> dhcp-range=tag:iot,192.168.255.10,192.168.255.100,72h


First, I tried to set tried to set the 'unknown' range as:

dhcp-range=tag:unknown,192.168.0.251,192.168.0.254,5m


But this didn't work for the static-lease hosts, because as they are known
but don't match any of the other tags, there was no range available for
them.

Then I tried to set it without any tag:

dhcp-range=tag:unknown,192.168.0.251,192.168.0.254,5m


But then the tagged devices (*iot*, *mobile* and *entertainment*) used it
despite having a specific range defined for their tag.

So the only way I found to get this work was denying tags:

dhcp-range=tag:!iot,tag:!mobile,tag:!entertainment,192.168.0.251,192.168.0.254,5m


And this works fine, but it doesn't look as an elegant solution to me, and
makes me to add a new denied tag every time I add/change a range.

So, I wonder if there is any way to set a last resort range only to be used
if there is not any other match.

Thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20210515/67f1fa42/attachment.htm>


More information about the Dnsmasq-discuss mailing list