Identifying DHCP Relay Agent

Simon Hobson dhcp1 at thehobsons.co.uk
Wed Jul 12 15:23:23 UTC 2006


William Lindén wrote:

>I'd like to set a different router depending on 
>via which router the request gets in. Idea would 
>be to use one bigger subnet instead of several 
>smaller, and with vrrp/hsrp etc etc, but thats a 
>different problem.. ;)

You mean, have several physically different 
networks sharing an IP subnet ? I'll be polite 
and just say - very inadvisable !

If you mean you have multiple routers on one 
subnet/one network, then use vrrp/hsrp and server 
up the virtual address to all the clients.

>Here's my config, but it just tells me no free 
>leases when I try to get an IP from the dhcp..
>
>----
>
>shared-network vrrp-test
>{
>
>  class "via_router1" {
>   match if packet (24,4) = "192.168.1.2";

You are comparing four bytes to an 11 character string !

You could convert the bytes to a string, or just 
specify the address as four bytes - eg :

match if packet (24,4) = c0:a8:1:2 ;

>   option routers 192.168.1.2;
>   }
>
>  class "via_router2" {
>   match if packet (24,4) = "192.168.1.3";
>   option routers 192.168.1.3;
>   }
>
>  subnet 192.168.1.0 netmask 255.255.255.0
>  {
>   pool
>   {
>   allow members of "via_router1";
>   allow members of "via_router2";
>   range 192.168.1.10 192.168.1.254;
>   option subnet-mask 255.255.255.0;
>   }
>  }
>}

Also, don't forget that in the general case, 
every broadcast packet from every client will 
come through BOTH routers - the server will get 
two packets, and make two replies. In theory the 
client can choose between the offers, in 
practice, clients generally just take the first 
offer.

Which will be the first offer ? It's 
indeterminate, but you will probably find that 
one router will be just a tad faster than the 
other and will get the forwarded packet to the 
server first.

If you just want to load-share across the two 
routers, a simpler way would be to do :

subnet 192.168.1.0 netmask 255.255.255.0 {
     pool {
       range 192.168.1.10 192.168.1.100;
       option routers 192.168.1.2
     }
     pool {
       range 192.168.1.101 192.168.1.200;
       option routers 192.168.1.3
     }
}


At first, clients will all get addresses from one 
pool, but once everything has been used once and 
addresses are being re-used then things will 
settle down to a pseudo-random selection between 
address pools.

Simon


More information about the dhcp-users mailing list