How does DHCPD determine what IP address to assign and...

Simon Hobson dhcp1 at thehobsons.co.uk
Wed Dec 26 23:17:16 UTC 2007


Ryan McCain wrote:

>The UID always looks something like this in the lease file::
>
>uid "\000cisco-10.116.6.251-Async32"
>
>Would this then be the correct syntax:?
>
>class "DialUp" {
>     match if substring(option vendor-class-identifier, 3,5) = "Async";
>         log (info, " Matched Dialup Rule");
>}
>
>subnet 10.116.6.0 netmask 255.255.255.0 {
>      pool {
>          allow members of "DialUp";
>          range 10.116.6.1 10.116.6.8;
>          option routers 10.116.6.1;
>          }
>}
>
>..Am I "calling" the "DialUp" class correctly so that any UID that 
>contains the string "Async" will be assigned an IP address between 
>10.116.6.1 - 10.116.6.8?

Apart from what David wrote re vendor-class-identifier vs 
dhcp-client-identifier, your match statement will NOT match.

Given that string for client-id, then substring 3,5 would return 
"sco-1" which is not "Async". For that particular string, you would 
need substring 20,5 - ie the 5 byte string starting at offset 20.

However, as I warned about earlier, the actual length of this string 
will change with IP address - eg if the client-id was 
"\000cisco-10.116.6.51-Async32" then you would need to look one byte 
earlier. If the ending is always "Async32" then you might be better 
using 'suffix(dhcp-client-identifier, 7)' which would return the last 
7 bytes.

Of course, if the 32 isn't constant, then you may well have to 
combine multiple statements to get what you need :

( (substring(suffix(dhcp-client-identifier,7),0,5)="Async")
  or
   (substring(suffix(dhcp-client-identifier,6),0,5)="Async") )

would match <anything>Asyncxx or <anything>Asyncx



Lastly, yes you are using the result correctly (as in 'allow members 
of ...'), but don't forget you will also have to deny these clients 
use of any other pools - otherwise you cannot guarantee that they 
will use this one.


More information about the dhcp-users mailing list