NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: dhcpd(8) and unused or old MAC addresses



Brett Lymn <blymn%internode.on.net@localhost> writes:

> On Tue, Aug 22, 2023 at 09:41:48AM -0400, Greg Troxel wrote:
>> 
>> > Is there a way to "free" their entries, to let dhcpd(8) forget about
>> > them, so that the relative IP addresses are re-usable? Each device
>> > which receives an IP address is recorded in /var/db/dhcpd.leases. Is it
>> > enough to manually delete its entry in that database file, or some
>> > other operation is needed?
>> 
>> This works and I do it all the time.
>
> The lease time is supposed to control how quickly the IP addresses are
> reused - half way through the lease time the client is supposed to renew
> the address, if this happens then the lease time is restarted.  If the
> client fails to renew the address and does not renew it at the expiry
> time then

This I agree with, finishing "the lease has expired and the address will
not be currently assigned"

> the address will be reused.

This isn't really true.   The address will be available for
reassignment, according to the protocol, so that if the server chose to
reuse it, it would not be wrong.

But dhcpd keeps track of previous leases long after their expiration; I
have had entires in the lease file from 6 months ago.  It will assign
addresses from the pool that have never been used for a lease, and then
I am pretty sure it will start reusing addresses probably in order of
least recently leased.  This is 100% compliant with the spec and means
that if a device gets an address and comes back next week, it will get
the same address.  I think this is what Rocky is seeing in the lease file.

> So, you could reduce your lease time so ephemeral devices will get a
> lease and it will be released quickly.  The balance being if you have
> devices that you want having the same address are off for a while then
> they may not get the same address again.  For those you could
> statically assing a particular mac address an IP and have another
> part of the range available for dynamic allocation.


I don't see lease time as very related here.  I'm using:

  default-lease-time 3600;
  max-lease-time 14400;

but I have leases in /var/db/dhcpd.leases from August 7th, and only then
because I cleaned out one from December.

1 hr, 1 day, is not going to matter much.  If you don't use all the
addresses, a returning device (with same mac addr) will get the same
address, even after a year.

I have observed Ubiquiti EdgeRouterLite (with their firmware; this isn't
port-mips :-) doing essentially the same thing with reusing addresses.


Home | Main Index | Thread Index | Old Index