Random lease IP address
dhcp1 at thehobsons.co.uk
Sun Aug 7 11:47:49 UTC 2011
Titanio Verde wrote:
>Is it possible to give random IP addresses from a subnet, instead of
>sequential ordered addresses (from the beginning)?
>I think I could with a previous version of dhcp3-server, without
>changing any option. But with the current stable one it doesn't.
It isn't an option and never has been.
The allocation algorithm is, in decreasing priority :
1) Allocate an address that has never been used before.
2) Re-allocate a previously used address on a least recently used basis.
3) Recover an abandoned lease.
Step 1 uses the order the unused addresses end up in a hash table,
which in the current implementation is top-down and sequential.
What you may have been seeing in the past is an "old" server with no
never-used addresses left. Once that state is reached, allocation
will appear random.
What you could do is to knock up a script that will create dummy
leases with random end times in the past and pre-pend that to the
leases file. So stop the server, stick a bunch of dummy leases on the
front of the leases file, restart the server. There will now be no
unused addresses and future allocations will now appear random - they
are actually determinate if you know the contents of the leases file,
but from an outside view they will now be "random".
Why prepend rather than append ? Well if you happen to duplicate an
existing lease, then by prepending the real lease entry will take
precedence as the server reads the leases file back in. That means
you can just create dummy leases for an entire range without having
to worry about conflicts.
Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.
More information about the dhcp-users