DHCP-Setup to serve two networks

Oliver Emslers ollee at gmx.net
Tue May 20 07:56:19 UTC 2008


Dear Simon,

ok, I have a Router with two DSL-Uplinks and two different public 
networks routed over each of them. Lets say over ppp0 87.1.1.0/25 and on 
ppp1 87.2.2.0/25. I want to assign this public networks via DHCP equally 
in a round-robin way to my internal clients, that approx. 50% are on 
ppp0 and 50% are on ppp1 to achieve some kind of load-balancing. Again, 
I know the disadvantages of this setup.

Ok, how can I achieve this. One way would be following:

subnet 87.1.1.0 netmask 255.255.255.128 { pool { range 87.1.1.1; option 
routers 87.1.1.126; option domain-name-servers 192.168.9.254; } }
  subnet 87.2.2.0 netmask 255.255.255.128 { pool { range 87.2.2.1; 
option routers 87.2.2.126; option domain-name-servers 192.168.9.254; } }
  subnet 87.1.1.0 netmask 255.255.255.128 { pool { range 87.1.1.2; 
option routers 87.1.1.126; option domain-name-servers 192.168.9.254; } }
  subnet 87.2.2.0 netmask 255.255.255.128 { pool { range 87.2.2.2; 
option routers 87.2.2.126; option domain-name-servers 192.168.9.254; } }
  subnet 87.1.1.0 netmask 255.255.255.128 { pool { range 87.1.1.3; 
option routers 87.1.1.126; option domain-name-servers 192.168.9.254; } }
  subnet 87.2.2.0 netmask 255.255.255.128 { pool { range 87.2.2.3; 
option routers 87.2.2.126; option domain-name-servers 192.168.9.254; } }
  subnet 87.1.1.0 netmask 255.255.255.128 { pool { range 87.1.1.4; 
option routers 87.1.1.126; option domain-name-servers 192.168.9.254; } }
  subnet 87.2.2.0 netmask 255.255.255.128 { pool { range 87.2.2.4; 
option routers 87.2.2.126; option domain-name-servers 192.168.9.254; } }
  subnet 87.1.1.0 netmask 255.255.255.128 { pool { range 87.1.1.5; 
option routers 87.1.1.126; option domain-name-servers 192.168.9.254; } }
  subnet 87.2.2.0 netmask 255.255.255.128 { pool { range 87.2.2.5; 
option routers 87.2.2.126; option domain-name-servers 192.168.9.254; } }

I tried that out and it works. The other way could be MAC-based. I just 
setup two classes and write substring declaration for the last octet of 
the mac-address like "match if substring ... 00 class ppp0; match if 
substring ... 01 class ppp1" and so on. I hope in a network with 200 
Clients that could be close to 50%. But isn't there a more elegant way 
doing it with DHCP?

Thanks!

Oliver


Simon Hobson schrieb:
> Oliver Emslers wrote:
> 
>> is there a easy way to share two (or more) public networks equally to 
>> internal clients to do some kind of minimal load balancing with DHCP? 
>> Just to have for instance approx. 50% clients on Network-A and 50% on 
>> Network-B with minimal Lease-Times. I know all the disadvantages this 
>> setup has, but that's not the question, please don't remind me! ;-) A 
>> working setup would be something like that:
>>
>> subnet 87.1.1.0 netmask 255.255.255.128 { range 87.1.1.1; option 
>> routers 87.1.1.126; option domain-name-servers 192.168.9.254; }
>>
>> subnet 87.2.1.0 netmask 255.255.255.128 { range 87.2.1.1; option 
>> routers 87.2.1.126; option domain-name-servers 192.168.9.254;  }
>>
>>
>> [...]
>>
>> and add every single ip to a separate subnet declaration. I already 
>> tried that out, it works. Isn't there a easier, more elegant way?
> 
> The question is really unclear ! You give an example of two subnets with 
> one usable IP in each, then make the statement "and add every single ip 
> to a separate subnet declaration" - do you mean you intend doing 
> something like this :
> 
> subnet 87.1.1.0 netmask 255.255.255.128 { range 87.1.1.1; option routers 
> 87.1.1.126; option domain-name-servers 192.168.9.254; }
> subnet 87.1.1.0 netmask 255.255.255.128 { range 87.1.1.2; option routers 
> 87.1.1.126; option domain-name-servers 192.168.9.254; }
> subnet 87.1.1.0 netmask 255.255.255.128 { range 87.1.1.3; option routers 
> 87.1.1.126; option domain-name-servers 192.168.9.254; }
> ...
> 
> or something like :
> subnet 87.1.1.0 netmask 255.255.255.128 {
>  range 87.1.1.1;
>  range 87.1.1.2;
>  range 87.1.1.3;
>  ...
>  option routers 87.1.1.126;
>  option domain-name-servers 192.168.9.254; }
> 
> The first is not valid, the second gives no advantage over :
> subnet 87.1.1.0 netmask 255.255.255.128 {
>  range 87.1.1.1 87.1.1.125;
>  option routers 87.1.1.126;
>  option domain-name-servers 192.168.9.254; }
> 
> Whichever way you define the ranges, the server allocates "never used" 
> addresses in a specific order (implementation dependent and not defined) 
> which at the moment is 'top down' - ie highest address first.
> 
> After a bit of churn, the address allocation will end up being 
> pseudo-random as addresses are reallocated on a least-recently-used 
> manner. If you wanted to randomise the allocation of leases to new 
> clients from the outset, then the simplest way would be to write a 
> script that generated random leases with a very short time and a bogus 
> client-id so as to 'seed' the leases file with leases that have 
> randomised expiry times.


More information about the dhcp-users mailing list