using variable

Simon Hobson dhcp at thehobsons.co.uk
Tue Mar 21 19:06:05 UTC 2006


Pierre LEONARD wrote:

>  >>i found how assign a value to a variable : /*set variable = "string"
>>>
>>>*/but now i would like to use this variable in order to assign fixed ip
>>>but get don't exists apparently because i have an "get: no such
>>>function" error in syslog after a successful lauching.
>>>any idea please ??
>>>   
>>>
>>
>>I'm fairly certain you can't (directly). The ISC DHSP server supports
>>only two modes that I know of, dynamic addresses and fixed addresses
>>specified with fixed-address statements in host declarations.
>>
>>However, there have been some convoluted methods suggested that
>>effectively create a class per client device and allow each client
>>access to a single address range. It's long winded, and I suspect not
>>very efficient, but it should work IFF you have a list of possible
>  >values known in advance.
>  >
>sorry for my impatience :-)
>in fact there is not a list of known value it's just a way for me to
>check that the packet come from a specific switch and vlan.
>if the paquet come from the good way i assign any value just to check
>and after i can say "if variable_test = "good_value" then assign this ip"
>i hope i'm clear when i speak in english !

So I think you want a test along the lines of :

   If (some condition based on switch & vlan)
     then set some-flag

Then later

   subnet a.b.c.0 ... {
     ...
     if (some-flag is set)
       then allow this client to have an address
   }

That is fairly easy to do :

class "vlan1-clients" { match if <insert conditions here> } ;

subnet a.b.c.0 ... {
   ...
   pool {
     range a.b.c.100 a.b.c.199 ;
     allow members of "vlan1-clients" ;
   }
}

Is this what you want, or have I misunderstood ?

Simon


More information about the dhcp-users mailing list