DHCP-Setup to serve two networks
Oliver Emslers
ollee at gmx.net
Tue May 20 10:13:22 UTC 2008
Dear Simon,
thanks for you answer. I do understand they way of prepolulating the
leases-file, but that's not an option for us in terms of doing this on
some hundreds of servers. What do you think about the approach of doing
this mac-address-based like this:
class "ppp0" {
match if substring (hardware, 6, 1) = 00;
match if substring (hardware, 6, 1) = 02;
[...]
}
class "ppp1" {
match if substring (hardware, 6, 1) = 01;
match if substring (hardware, 6, 1) = 03;
[...]
}
subnet 87.1.1.0 netmask 255.255.255.128 {
pool {
allow members of "ppp0";
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 {
pool {
allow members of "ppp1";
range 87.2.2.1 87.2.2.125;
option routers 87.2.2.126;
}
}
there should be quite a good chance of equalizing the two networks from
a ip-based point of view ... I have to check this out ... ;-)
Oliver
Simon Hobson schrieb:
> 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