DHCP-Setup to serve two networks

Simon Hobson dhcp1 at thehobsons.co.uk
Tue May 20 09:31:14 UTC 2008


Oliver Emslers wrote:

>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.

I'm surprised it works, it's not a valid configuration (subnets 
declared more than once) and is liable to break any time you upgrade 
the software. It also will NOT do what you are asking for, which is 
not actually possible with the ISC server.

I've already given you a suggestion how to achieve something that 
approximates what you want to do :

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; }

subnet 87.2.2.0 netmask 255.255.255.128 {
  range 87.2.2.1 87.2.2.125;
  option routers 87.2.2.126; }

and pre-populate the leases file. Or you could start with the ranges 
much smaller and expand them as clients log leases addresses.

Note that the 'round-robin' approach will ONLY work while there are 
addresses that have NEVER been used, once all addresses have been 
used then future assignments are done on a least recently used basis.

You could pre-allocate leases to force an initial round-robin 
allocation with a simple script like this :

a=1 ; while [ $a -lt 125 ]
do
   echo "lease 87.1.1.1 {
   starts 0 2008/01/01 00:$a:00;
   ends 0 2008/01/01 00:$a:01;
   binding state free;
   hardware ethernet 00:00:00:00:00:00;
}
lease 872.2.1 {
   starts 0 2008/01/01 00:$a:00;
   ends 0 2008/01/01 00:$a:01;
   binding state free;
   hardware ethernet 00:00:00:00:00:00;
}" >> new_leases
   a=$(( $a + 1 ))
done

It will need a bit more to deal with a<10 (need to add a leading 0) 
and a>59 (need to deal with rollover of the minute) - but that should 
give you an idea.



More information about the dhcp-users mailing list