[Dnsmasq-discuss] dhcp-host wildcard matching

Simon Kelley simon at thekelleys.org.uk
Wed Nov 13 13:51:26 GMT 2013


On 09/11/13 21:23, Swarvek Swiac wrote:
> Hi
>
> I had a look at the documentation but couldn't find if there is a way
> to do wildcard match for host name in dhcp-host option. I'm not after
> anything fancy, just simple substring search.
>
> In my case I'm trying to set specific options for Android devices,
> unfortunately the vendor-class being sent by some devices is just
> "dhcpcd" followed by version (e.g. dhcpcd-5.5.6). The only way to
> filter them out is by hostname which always starts with "android"
> followed by either underscore and then mac address (e.g.
> android_0016DC6B7960) or hyphen and series of numbers (e.g.
> android-4701ead57dcd49c1).
>

The best way to attack this is with dhcp-match, which can match 
arbitrary substrings in arbitrary options.

There are a couple if gotchas to worry about.

1) There's a bug in releases before 2.66 that means the some option 
names are not recognized, option numbers always work.

2) The android dhcp client may be supplying the information is a 
hostname option (option 12) or a FQDN option (option 81)


So something like


dhcp-match=set:is_android,12,"android"

or

dhcp-match=set:is_android,81,"android"

should give you a tag that you can use to discriminate.

As usual, set --log-dhcp when testing, to check you're getting the tags 
you expect.


Cheers,

Simon.



More information about the Dnsmasq-discuss mailing list