dhcpd.conf variables?
Ray Phillips
r.phillips at uq.edu.au
Wed Oct 14 08:52:47 UTC 2009
Is it possible to create and use variables in dhcpd.conf? I'd like
to be able to put strings and integers in a temporary place and
recall them later.
At first I thought it might be possible to create a new option space
for this, but then I saw a notice in the DHCP Handbook saying option
values are assigned when the daemon starts and cannot be modified
afterwards.
At the moment I want to use variables to create a log message showing
the actual switch port to which a dhcp client is connected, not the
code for the port that Cisco 3560s send in option 82 [1].
I was hoping to be able to progressively assemble the components of
the log message I want by storing the relevant data in variables,
something like:
switch-name = substring (option agent.remote-id, 2, 256);
(Our 3560s have been configured to send the switch name as an ASCII
string in option 82.)
opt82.port-code = suffix (option agent.circuit-id, 1);
then use an if{ } elsif{ } chain to convert the port code to the
actual port, and concat the pieces into the log message, but perhaps
that's in the realms of fantasy?
Presumably only having to extract the port code once, then assign it
to a variable and test that variable's value against the possible
codes would save a fair bit of CPU time, as opposed to executing
'suffix (option agent.circuit-id, 1)' for each possible port code.
There isn't a 'less than' or 'greater than' test available in dhcpd is there?
Ray
[1]
3560 48 port switch
Real Reports As
Gi0/1 Port 1/1
Gi0/2 Port 1/2
Fa0/1 Port 1/3
Fa0/2 Port 1/4
Fa0/3 Port 1/5
Fa0/4 Port 1/6
Fa0/5 Port 1/7
Fa0/6 Port 1/8
Fa0/7 Port 1/9
Fa0/8 Port 1/10
Fa0/9 Port 1/11
Fa0/10 Port 1/12
Fa0/11 Port 1/13
Fa0/12 Port 1/14
FA0/13 Port 1/15
Fa0/14 Port 1/16
Fa0/15 Port 1/17
Fa0/16 Port 1/18
Fa0/17 Port 1/19
Fa0/18 Port 1/20
Fa0/19 Port 1/21
Fa0/20 Port 1/22
Fa0/21 Port 1/23
Fa0/22 Port 1/24
Fa0/23 Port 1/25
Fa0/24 Port 1/26
Gi0/3 Port 1/27
Gi0/4 Port 1/28
Fa0/25 port 1/29
Fa0/26 Port 1/30
Fa0/27 Port 1/31
Fa0/28 Port 1/32
Fa0/29 Port 1/33
Fa0/30 Port 1/34
Fa0/31 Port 1/35
Fa0/32 Port 1/36
Fa0/33 Port 1/37
Fa0/34 Port 1/38
Fa0/35 Port 1/39
Fa0/36 Port 1/40
Fa0/37 Port 1/41
Fa0/38 Port 1/42
Fa0/39 Port 1/43
Fa0/40 Port 1/44
Fa0/41 Port 1/45
Fa0/42 Port 1/46
Fa0/43 Port 1/47
Fa0/44 Port 1/48
Fa0/45 Port 1/49
Fa0/46 Port 1/50
Fa0/47 Port 1/51
Fa0/48 Port 1/52
More information about the dhcp-users
mailing list