in reply to getting non-default dhcp option value
my $data; my $subnet; my $ip = qr/((?:\d{1,3}\.){3}\d{1,3})/; while(<DATA>){ /subnet\s+$ip\s+netmask\s+$ip/ and $subnet = $1 and $data->{"subnet:$subnet"} = { ip => $1, mask => $2, }; /range\s+$ip\s+$ip/ and $data->{"subnet:$subnet"}{range} = { ip => $1, mask => $2, }; /option\s+routers\s+$ip/ and $data->{"subnet:$subnet"}{routers} = { ip => $1 }; /option\s+domain-name\s+"(\S+)"/ and $data->{"subnet:$subnet"}{'domain-name'} = { 'hostname', $1 }; /option\s+domain-name-servers\s+(.+?)\W*$/ and $data->{"subnet:$subnet"}{'domain-name-servers'} = { 'hostname', [ split /,/, $1 ] }; /option\s+option-222\s+"(\S+)"/ and $data->{"subnet:$subnet"}{'option-222'} = { 'hostname', $1 }; } use Data::Dumper;die Dumper($data); __DATA__ subnet 192.168.125.0 netmask 255.255.255.0 { range 192.168.125.200 192.168.125.250; option routers 192.168.125.10; option domain-name "pillepalle.de"; option domain-name-servers 192.168.125.10, 192.168.101.15; option option-222 "http://pillepalle.de:8080"; } __END__ stdout: $VAR1 = { 'subnet:192.168.125.0' => { 'routers' => { 'ip' => '192.168. +125.10' }, 'ip' => '192.168.125.0', 'domain-name-servers' => { 'host +name' => [ + '192.168.125.10', + ' 192.168.101.15' + ] }, 'domain-name' => { 'hostname' => + 'pillepalle.de' }, 'range' => { 'ip' => '192.168.12 +5.200', 'mask' => '192.168. +125.250' }, 'option-222' => { 'hostname' => +'http://pillepalle.de:8080' }, 'mask' => '255.255.255.0' } };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: getting non-default dhcp option value
by morlix (Initiate) on Sep 15, 2005 at 10:11 UTC |