LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Dhcpd.leases issue (https://www.linuxquestions.org/questions/linux-networking-3/dhcpd-leases-issue-4175425647/)

blackbrayn 09-04-2012 05:02 PM

Dhcpd.leases issue
 
Hi, everything works as intended with my dhcp server but i use a php script to keep track of the leases , in the leases file i see "duplicate" entries like this:

lease 10.240.21.36 {
starts 2 2012/09/04 20:38:03;
ends 2 2012/09/04 20:39:03;
tstp 2 2012/09/04 20:39:03;
cltt 2 2012/09/04 20:38:03;
binding state free;
hardware ethernet 00:a8:59:c8:55:fe;
uid "\001\000\250Y\310U\376";
}

lease 10.240.21.36 {
starts 2 2012/09/04 20:37:32;
ends 2 2012/09/04 20:38:32;
cltt 2 2012/09/04 20:37:32;
binding state active;
next binding state free;
hardware ethernet 00:a8:59:c8:55:fe;
uid "\001\000\250Y\310U\376";

yes , there are diferent states and practicaly dhcpd writes a log in a cronologic order , but , even after some time these remain there like in a log file even if the clients are not present anymore .

This behavior is documented in the dhcpd.leases man :

The lease file is a log-structured file - whenever a lease changes, the contents of that lease are written to the end of the file. This means that it is entirely possible and quite reasonable for there to be two or more declarations of the same lease in the lease file at the same time. In that case, the instance of that particular lease that appears last in the file is the one that is in effect.

And now the question is: can we alter this behavior or the time after dhcpd decides to clean it?

Please don't tell me to put a cron job to clear the file , that's not a solution .

Thx for reading the long post.

Ygrex 09-07-2012 07:58 PM

this file intended to be handled automatically, so generally you cannot shrink it whenever you want; also doing that with a cron job is not a trivial task as well

Reuti 09-08-2012 02:59 PM

Quote:

Originally Posted by blackbrayn (Post 4772681)
This behavior is documented in the dhcpd.leases man :

The lease file is a log-structured file - whenever a lease changes, the contents of that lease are written to the end of the file. This means that it is entirely possible and quite reasonable for there to be two or more declarations of the same lease in the lease file at the same time. In that case, the instance of that particular lease that appears last in the file is the one that is in effect.

In the next section it’s mentioned to use { deleted; }, maybe you have to create host specific entry for this MAC address, so that it can be removed from the dhcpd.leases file.

blackbrayn 09-12-2012 05:08 PM

thx for you time , after all i decided to leave the dhcpd.leases untouched and work on the php interface that reads from it and displays the leases in a web page.
Anyway just to mention , old logs from the dhcpd.leases get cleaned after a restart (isc-dhcp server restart).


All times are GMT -5. The time now is 11:55 AM.