how dhcp-server select a ip-address to client?

Simon Hobson dhcp1 at thehobsons.co.uk
Mon Mar 5 13:13:24 UTC 2012


18905913309 wrote:

>i have noticed that the dhcp-clientst's ip address will keep same in 
>most time,even if it released ip-address,then send dhcp-discover in 
>isc-dhcp-server.so i think if server will watch the dhcpd.leases to 
>find if has a mac-address record in it,then offer the associated 
>ip-address to client.

Correct, but more specifically it's the Client ID that is used as the 
primary key, and the MAC address only if a Client ID is not supplied. 
This is in accordance with the RFC which **requires** the server to 
attempt to give each client the same address as it last had - even if 
the lease has expired or been released (the Microsoft server isn't 
compliant in this respect).

>but i do observed that client's ip-address changed in some time even 
>if it's dhcp-server's configration remained unchanged and the pools 
>has only been used 60%.
>
>can anybody know in which condition that the dhcp-server will offer 
>a different ip-address to client?

The allocation logic is :

Examine the Client ID, or if that is not supplied, the MAC address. 
Then search teh leases database for previous lease(s) allocated to 
this client in the relevant subnet.

+ If the client requests a specific address, and that address is 
available and valid for the subnet, then offer that address.
+ If there is a matching record, lease out the same address as the 
client previously had.
+ If there is no matching record, then allocate an address in the 
following order of descending priority :
- A previously unused address (ie an address which does not have any 
prior lease record). The order of allocation/selection method is 
implementation specific and undefined.
- A previously used address (ie one that has been leased to a 
different client in the past) on a least recently used basis.
- An address marked abandoned* in the database.
If the above fail, then no address is offered and you'll see "no free 
leases" in the log.

* Addresses are abandoned when it is selected to be offered, but a 
ping shows that the address is actually in use.

The key reasons a client will change it's address :
1) It requests a specific address.
2) It presents a different Client ID, presents a Client ID when one 
was not previously presented, or does not present a Client ID when 
one was previously presented.
3) It's previous address has been given to a different client.

The Client ID/no Client ID issue comes into play when systems 
multiboot. Eg, a system may first request an address for a PXE client 
(typically not supplying a Client ID), and then boot an OS (eg 
Windows) which does supply a Client ID. In this case, the two clients 
are completely different as far as the server is concerned and will 
get separate leases which will be tracked separately.

There is of course a whole class of exception that come into play 
when the administrator changes the address ranges on offer or applies 
rules (eg by classing) as to which clients may use which pools.

-- 
Simon Hobson

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 mailing list