DHCP Lease

Gregory Sloop gregs at sloop.net
Wed Jun 8 18:59:56 UTC 2022


You can stop the dhcpd server and edit the leases file and remove the lease.
 
That doesn't follow the RFC for how leases are handled, and if you have a ddns entry that was generated by the lease, it won't get removed.
There are probably other undesirable side-effects I can't think of at the moment too.
 
You'll also need to make sure that client doesn't continue to attempt to use the lease it was promised, and hasn't expired yet. Different clients handle that differently.
 
But you're breaking the rules for dhcpd leases, so you have to work around those problems.
 
I think that answers your question - but it perhaps misses the more important factor of "Why?"
Why are you wanting to delete a lease? (One off mistake, and you'll handle the fallout? Probably fine. You want to do this systemically? Quite ugly with lots of complications.)
 
There's been a lot of discussion on the list over the years about admins wanting to force all leases to get new IP's at expiration, cause them to end early etc. And there's a lot of reasons those ideas are often bad - some more bad than others. Thus, knowing what you're trying to accomplish might help us offer more than a set of steps to do what you asked, and more along the lines of "Is this a good idea that has practical merit?" (Probably not, but it might be worth some consideration.) :)

-Greg
 

> Hi, community,
> I want to delete a lease, for example, this one below instead of waiting eight hours. What is the correct way to do it? I mean, I do not want to screw the DHCP service up. So, could someone give me some advice to approach this task? Thanks a lot.
>> /var/lib/dhcp/dhcpd.leases
>> lease DIR-IP-X.X.X.X {
>>   starts 3 2022/06/08 10:42:28;
>>   ends 3 2022/06/08 18:42:28;
>>   tstp 3 2022/06/08 18:42:28;
>>   cltt 3 2022/06/08 10:42:28;
>>   binding state active;
>>   next binding state free;
>>   rewind binding state free;
>>   hardware ethernet DIR-MAC-X:X:X:X;
>>   uid "\001\304\015\2264\243\376";
>>   set agent-id = "DIR-IP-X.X.X.X";
>>   set hstnm = "EG8145X6";
>>   set clhw = "DIR-MAC-X:X:X:X";
>>   set clip = "DIR-IP-X.X.X.X";
>>   set cllt = "28800";
>>   set hsttype = "pc";
>>   set tech = "gpon";
>>   set clrid = "34:38:35:37:35:34:34:33:44:33:42:46:45:31:41:37";
>>   set clcid = "4d:41:44:52:49:44:5f:30:31:20:78:70:6f:6e:20:30:2f:31:31:2f:30:2f:31:33:3a:34:2e:32:2e:32:30:30:25";
>>   option agent.circuit-id "XXXXX_01 xpon 0/11/0/13:4.2.200%";
>>   option agent.remote-id "48575443D3BFE1A7";
>>   client-hostname "EG8145X6";
>>   on expiry {
>>     set clip =
>>        binary-to-ascii (10, 8, ".", leased-address) ;
>>     execute ("/opt/fos/bin/push_ip_lease", "--transaction=expiry",
>>         concat ("--leased-address=", clip));
>>   }
>>   on release {
>>     set clip =
>>        binary-to-ascii (10, 8, ".", leased-address) ;
>>     execute ("/opt/fos/bin/push_ip_lease", "--transaction=release",
>>         concat ("--leased-address=", clip));
>>   }
>> } Best,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20220608/979b3f34/attachment.htm>


More information about the dhcp-users mailing list