what part of dhcpd.leases file is moved (or copied) to dhcpd.leases~?

Simon Hobson dhcp1 at thehobsons.co.uk
Sun Jan 21 23:30:32 UTC 2007


Luc T. wrote:

>what part of dhcpd.leases file is moved (or copied) to dhcpd.leases~?

Every lease record held in memory - including expired leases.

>   I am always confused with this question, as I can see new (in term 
>of starting time) leases in dhcpd.leases~, while older leases are 
>still sitting in dhcpd.conf.
>   
>   From the man dhcpd.leases, it says
>   
>   "First,  a  temporary lease   database   is   created   and   all 
>known   leases  are  dumped  to  it.    Then,  the  old  lease 
>database  is  renamed /var/lib/dhcp/dhcpd.leases~.   Finally, the 
>newly written lease database is moved into place."
>   
>   It seems to me that
>
>   1. when this happens, the new dhcpd.leases should be almost empty 
>or contain only a few records.

No - you are assuming that only current leases are copied.

>   2. the dhcpd.leases and dhcpd.leases~ can be linked together to 
>form a more complete, bigger leases file.

No, once the new leases file is made active, the old file is 
redundant. It will contain nothing that is not in the current file 
other than superceded records.

>   Am I right?

No, as stated above. What I think you are missing is that the server 
does not delete lease records when they expire - it simply marks them 
as free for reuse. This is done to minimise address churn/increase 
stability, as in a client may disappear from the network for a while 
and then return. With the ISC server, the client will get the same 
address unless it has had to be reused - with other servers, client 
may well get a different address each time they come back to the 
network.


Also, to answer another thread, when the new leases file is written, 
only one record/lease is written and it does not matter what order 
they appear. Hence it is quite possible that as you follow the 
physical order of records you will find that they aren't in 
chronological order. Actaully, due to the way the leases are indexed 
in different lists (depending on state) and using a hashing function, 
it's highly likely that they will NOT be written in chronological 
order.

Once the server starts amending lease records however, all NEW 
records will be appended in chronological order - it is only when you 
have two or more records for a specific lease that the order becomes 
important.


More information about the dhcp-users mailing list