Koozali.org: home of the SME Server

dhcp.leases retains ancient leases - why?

Rob Wellesley

dhcp.leases retains ancient leases - why?
« on: September 25, 2003, 06:16:27 PM »
I notice that dhcp.leases retains records of leases for MAC addresses long since gone. Also - occasionally there are 2 or 3 leased IP's to the same host - different date periods tho.

Any ideas why? and what would happen once current scope is gone (we build PC's and load software from our network)?

How come the lease file isn't "flushed" regularly? the oldest lease record we have is July 30.

Any comments form the learned and experienced appreciated

rob

Jim Danvers

Re: dhcp.leases retains ancient leases - why?
« Reply #1 on: September 25, 2003, 11:14:38 PM »
Yeah...   good question.  I too would like to know of a means / method to periodically clear the leases pool.  I installed a little contrib that shows what leases are in use - kinda cool.  I'd like to be able to 'manage' the pool too (simply in the respect of clearing/flushing it).

-=- jd -=-

Byte

Re: dhcp.leases retains ancient leases - why?
« Reply #2 on: September 25, 2003, 11:47:28 PM »
This is what I use to clear my DHCP Leases every month via cron

Type at command line or create a bash script - do the following

 /etc/rc.d/init.d/dhcpd stop
 rm /var/lib/dhcp/dhcpd.*
 touch /var/lib/dhcp/dhcpd.leases
 /etc/rc.d/init.d/dhcpd start


Hope this helps you

Byte

Jim Danvers

Re: dhcp.leases retains ancient leases - why?
« Reply #3 on: September 26, 2003, 12:39:38 AM »
Groovy...   thanks.  ;)

-=- jd -=-

Rob Wellesley

Re: dhcp.leases retains ancient leases - why?
« Reply #4 on: September 26, 2003, 01:16:39 AM »
Byte wrote:
>
> This is what I use to clear my DHCP Leases every month via cron

Sure  - but you'd want every one logged off and shut down tho' right? otherwise the next guy to turn on a PC will get the first IP in the scope - which may be already in use on a PC that's running  - OUCH

rob

Jon Blakely

Re: dhcp.leases retains ancient leases - why?
« Reply #5 on: September 26, 2003, 01:42:09 AM »
What you want is e-smith-dhcpmanager-1.2-8 from

http://www.developit.fr/FichePratique/SMEServer/index.html

I found it last night and installed it. Works well. Shows you the leases, which ones are active or not, and allows you to remove leases.

Jon

Jim Danvers

Re: dhcp.leases retains ancient leases - why?
« Reply #6 on: September 26, 2003, 03:36:03 AM »
Ahh!!  ... and this one works w/5.6 boxes?  (I'm @work right now and haven't looked yet - will though.  ;) )

Thanks for the link / post.

-=- jd -=-

Charlie Brady

Re: dhcp.leases retains ancient leases - why?
« Reply #7 on: September 26, 2003, 06:38:36 AM »
Rob Wellesley wrote:
>
> I notice that dhcp.leases retains records of leases for MAC
> addresses long since gone. Also - occasionally there are 2 or
> 3 leased IP's to the same host - different date periods tho.

An expired lease is an expired lease. Why worry about it?

> Any ideas why?

You'd have to ask on the dhcpd design list. Probably just not worth purging.

Charlie

Mark

Re: dhcp.leases retains ancient leases - why?
« Reply #8 on: September 26, 2003, 08:02:52 AM »
>An expired lease is an expired lease. Why worry about it?

How do you know it's expired?

>You'd have to ask on the dhcpd design list. Probably just not worth >purging.

If it's not work keeping it's worth purging.

Mark

Charlie Brady

Re: dhcp.leases retains ancient leases - why?
« Reply #9 on: September 26, 2003, 09:28:20 AM »
Mark wrote:

> >An expired lease is an expired lease. Why worry about it?
>
> How do you know it's expired?

This seems very obvious to me - an expired lease is one whose expiry time is in the past (what else could an expired lease be?).

> >You'd have to ask on the dhcpd design list. Probably just
> > not worth purging.
>
> If it's not work keeping it's worth purging.

If you think so, then you are free to add the code. Note, however, that more code very often means more bugs.

Is it currently broken? Seems at most a cosmetic fault to me - and if so, it should have a cosmetic fix - whatever is displaying the expired leases should be modified to ignore them.

Further discussion should be directed to the dhcpd devel list.

Charlie

Michiel

Re: dhcp.leases retains ancient leases - why?
« Reply #10 on: September 26, 2003, 12:08:48 PM »
According to man dhcpd.leases "the file is rewritten from time to time". Apparently that is once an hour in the absence of activity, or after every thousand
leases that are written. It looks like Mitel changed that behaviour?

But as Charlie said, it doesn't really matter. Eventually it gets flushed and the file never even approaches the size of, say, /var/log/messages.

It even provides you with some forensic evidence. For example, your logs tell you that IP 192.168.208.69 did something naughty yesterday at 14:05 and you need to know who that bugger was. Have a look in dhcpd.leases and you'll know his MAC address.

Michiel

Byte

Re: dhcp.leases retains ancient leases - why?
« Reply #11 on: September 26, 2003, 02:05:02 PM »
Rob Wrote:

>Sure - but you'd want every one logged off and shut down tho' right? otherwise >the next guy to turn on a PC will get the first IP in the scope - which may be >already in use on a PC that's running - OUCH

>rob

Not really because the cron runs at midnight ;-)

Byte

Rob Wellesley

Re: dhcp.leases retains ancient leases - why?
« Reply #12 on: September 26, 2003, 02:51:00 PM »
> Rob Wrote:
>
> >Sure - but you'd want every one logged off and shut down

Byte wrote:
> Not really because the cron runs at midnight ;-)
>

If a PC is left running over night it won't matter when the script runs - that PC will retain it's IP till reboot or end of lease. If it's IP is the first in the scope - and the first PC to boot up in the morning pickups the same IP from DHCPD - (because there is no record of the tie between MAC and IP addresses - because ot the blank dhcp.leases) you will have conflicts.  Or am I missing something here?

rob