howto :add route to client
DHCP-User Nick
dhcp at kld.ru
Tue Mar 11 07:07:27 UTC 2008
Guy Deleeuw wrote:
> Hello
>
> It is possible to add different route to dhcp clients ?
> like :
> route add -net 192.168.5.0 netmask 255.255.255.0 gw 192.168.3.198
>
> Regards
>
> Guy
>
>
Hi,
you can look for option classless-route code 249.
It's a dhcp option with code for windows.
But it's work for windows_XP and newer. Not for windows_2000!
Linux work fine of course.
dhcpd.conf example:
option classless-route code 249 = string;
host aaaa {
...............
option classless-route 08:0a:0a:01:01:01;
}
---------------------------------
and howto get a strange parameter (perl example):
#!/bin/perl
$router_ip = '10.0.0.1';
# 10.0.0.0/8 - your network
print make_classless_option({"10.0.0.0/8" => "$router_ip"});
exit;
sub make_classless_option
{
my $routes = shift;
my ($s1, $s2, $s3, $s4, $len, @bytes, $net, $mask, $destination,
$router);
$len = 2;
@bytes = ();
foreach $destination(keys %{$routes}) {
($net, $mask) = split('/', $destination);
$router = $routes->{$destination};
($s1, $s2, $s3, $s4) = split(/\./, $net);
push(@bytes, sprintf('%02x', $mask));
push(@bytes, sprintf('%02x', $s1));
push(@bytes, sprintf('%02x', $s2)) if($mask > 8);
push(@bytes, sprintf('%02x', $s3)) if($mask > 16);
push(@bytes, sprintf('%02x', $s4)) if($mask > 24);
($s1, $s2, $s3, $s4) = split(/\./, $router);
push(@bytes, sprintf('%02x', $s1));
push(@bytes, sprintf('%02x', $s2));
push(@bytes, sprintf('%02x', $s3));
push(@bytes, sprintf('%02x', $s4));
}
return join(':', @bytes);
}
Good luck!
nick
More information about the dhcp-users
mailing list