using variable

Pierre LEONARD pier.leonard at free.fr
Tue Mar 21 19:36:21 UTC 2006


Simon Hobson a e'crit:
>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
>
>
>
>  
>
you understood my problem but there is another problem:

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

*/it's not possible to use my variable instead of "<insert conditions 
here>" and i don't why
i can just use it like following:

/*set test = "value";
if test = "value" {<treatement>;}
*/
and the treatment cannot be a block subnet, shared-network, pool, class...
so i'm blocked



_my complete code:_

#checking vlan
if (binary-to-ascii (10, 16, "", substring( option agent.circuit-id, 2, 
2))= "10" {
log(info , "checking vlan");

#checking switch
if binary-to-ascii(16, 8, ":", substring( option agent.remote-id, 2, 6)) 
= "<mac address>") {
log( info, "checking switch mac address");
set test = "ok";
}
}

#*********************************************class 
definitions**************************************************
class "port20" {
match if binary-to-ascii (10, 8, "/", suffix( option agent.circuit-id, 
2)) = "0/19";
# match if test = "ok"; #launch but don't function
}

class "port21" {
match if binary-to-ascii (10, 8, "/", suffix (option agent.circuit-id, 
2)) = "0/20";
# match if test = "ok"; #launch but don't function
}


#*******************************************leases 
definitions***************************************************
shared-network 1 {
subnet 192.168.0.0 netmask 255.255.255.0 {
authoritative;
}

pool {
allow members of "port20";
deny members of "port21";
range 192.168.0.20;
}

pool {
allow members of "port21";
deny members of "port20";
range 192.168.0.21;
}
}



i would like to do something like:

match if first condition and test="ok";




More information about the dhcp-users mailing list