[EXT] Re: Why is dhcpd not matching the MAC address as it should

Andrew Falanga (afalanga) afalanga at micron.com
Wed Jan 17 21:27:25 UTC 2018


> > class "controller" {
> >    # tried matching based on two different styles I've seen on the net
> >    #match if substring(hardware, 1, 3) = 00:a0:45;
> >    match if (binary-to-ascii(16, 8, ":", substring(hardware, 0, 4)) =
> "1:00:a0:45");
> >    log(info, "found a controller");
> > }
> Are you sure the “1:” is needed? I don’t think so.

This is actually an irritating hole in the documentation.  It isn't truly clear what "hardware" returns nor is it made clear which method is "better" than the other.  I've tried both

match if substring(hardware, 1,3) = 00:a0:45;

and 

match if (binary-to-ascii(16, 8, ":", substring(hardware, 0, 4)) = "1:00:a0:45");

The one thing I do know for sure, the hardware operator returns, in addition to the MAC, the "type" field which is part of the bootp/dhcp header.  In this case, because it is Ethernet, it is 1.  In the first match, I'm only looking for the MAC  so the address is from 1 - 3 of the hardware "data-string" (the docs name for it, it doesn't elaborate anywhere that I know what a *data-string* is, from the usage in the config file, it's a *string*).  I'm pretty sure the first form of usage could be re-written as

match if substring(hardware, 0, 3) = 1:00:a0:45;

but I truthfully haven't tested it.

Andy


More information about the dhcp-users mailing list