Matching against the "hardware" String

Simon Hobson dhcp1 at thehobsons.co.uk
Thu Nov 18 08:06:43 UTC 2010


Martin McCormick wrote:
>I wrote a class statement that checks the first 6 characters in
>the host name as in
>
>class "Certain-Systems" {
>match if substring (option host-name, 0, 6) = "ABCDE0";
>}
>
>It works. I want to also write a statement that uses the manufacturer's
>unique identifier portion of the MAC address. Do I need to
>actually allow for 9 characters due to the colons that are
>usually found as separaters or if the digits were aa:bb:cc,
>would aabbcc match since that is technically the first 6
>characters of the address?

Your options are to either convert to a string and do a string match, 
or just do a binary match.

"aa:bb:cc" is a string of EIGHT characters. aa:bb:cc is a binary 
value of length THREE octets. So :

substring (hardware,1,3) = aa:bb:cc
would match the manufacturer part (OUI) of the MAC address. Note that 
you start at position 1 (ie the second byte) as the hardware field 
contains a leading 1 for ethernet. You could also do :
substring (hardware,0,4) = 1:aa:bb:cc


-- 
Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.



More information about the dhcp-users mailing list