Netgate SG-1000 microFirewall

Author Topic: DHCP Lease Delete Button - $30  (Read 19161 times)

0 Members and 1 Guest are viewing this topic.

Offline djamp42

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +4/-0
    • View Profile
DHCP Lease Delete Button - $30
« on: April 16, 2009, 05:07:47 pm »
Can someone add a simple delete button for a single DHCP lease. Multiple leases also preferred but not required.

 ;D ;D

Offline jimp

  • Administrator
  • Hero Member
  • *****
  • Posts: 21404
  • Karma: +1437/-26
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #1 on: April 16, 2009, 05:51:28 pm »
Shouldn't be too hard to do, stop dhcpd, read the leases, write back all except the record to delete, and then restart dhcpd

I was looking at this earlier today.

ISC DHCPD has a directive for the leases file that is supposed to cause it to delete an existing lease, but I could not get it to work.
Need help fast? Commercial Support!

Co-Author of pfSense: The Definitive Guide. - Check the Doc Wiki for FAQs.

Do not PM for help!

Offline jimp

  • Administrator
  • Hero Member
  • *****
  • Posts: 21404
  • Karma: +1437/-26
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #2 on: April 16, 2009, 07:26:05 pm »
I have this working now, but needs testing. Any volunteers?
« Last Edit: April 16, 2009, 07:46:31 pm by jimp »
Need help fast? Commercial Support!

Co-Author of pfSense: The Definitive Guide. - Check the Doc Wiki for FAQs.

Do not PM for help!

Offline jimp

  • Administrator
  • Hero Member
  • *****
  • Posts: 21404
  • Karma: +1437/-26
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #3 on: April 16, 2009, 10:30:23 pm »
Limited testing seems to have worked OK.

Patch committed to HEAD (2.0).

I am also going to make sure that when adding a static DHCP mapping, the old dynamic lease for the MAC is removed. Currently this results in a duplicate lease and a warning from dhcpd. After that point, this work may make it into 1.2.3 as a bug fix.
Need help fast? Commercial Support!

Co-Author of pfSense: The Definitive Guide. - Check the Doc Wiki for FAQs.

Do not PM for help!

Offline AhnHEL

  • Hero Member
  • *****
  • Posts: 636
  • Karma: +18/-0
  • It is what it is.
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #4 on: April 16, 2009, 10:42:07 pm »
Seems to be working well on my pf box.  Much appreciated, thx.
AhnHEL (Angel)
NYC

2 pfSense sites: 2.4.2 (amd64)
Dell 755 SFF E6550 @ 2.3Ghz, 4GB RAM, 100/30 Mbps, Intel X3959
Dell 7010 SFF i5-3570 @ 3.4Ghz, 8GB RAM, 940/880 Mbps, Intel X3959
OpenVPN (Road Warrior), pfBlockerNG, Gaming


Offline wonslung

  • Full Member
  • ***
  • Posts: 150
  • Karma: +0/-0
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #5 on: April 16, 2009, 11:26:10 pm »
will this patch work on 1.2.3

Offline jimp

  • Administrator
  • Hero Member
  • *****
  • Posts: 21404
  • Karma: +1437/-26
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #6 on: April 17, 2009, 06:49:32 am »
will this patch work on 1.2.3


The file I posted is for 1.2.2/1.2.3, yes. However, the code tree for 1.2.3 is restricted from general committing so I could only commit the patch to HEAD. When I get the other issues straightened out I will submit the patches for consideration for 1.2.3. The fix is the same for both branches.
Need help fast? Commercial Support!

Co-Author of pfSense: The Definitive Guide. - Check the Doc Wiki for FAQs.

Do not PM for help!

Offline wonslung

  • Full Member
  • ***
  • Posts: 150
  • Karma: +0/-0
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #7 on: April 17, 2009, 07:19:13 am »
i tried it in 1.2.3 and it didn't change anything

Offline jimp

  • Administrator
  • Hero Member
  • *****
  • Posts: 21404
  • Karma: +1437/-26
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #8 on: April 17, 2009, 07:44:20 am »
The choice to delete will only appear for offline leases.

I suppose that could be changed, but that seemed the safest course of action.
Need help fast? Commercial Support!

Co-Author of pfSense: The Definitive Guide. - Check the Doc Wiki for FAQs.

Do not PM for help!

Offline djamp42

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +4/-0
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #9 on: April 17, 2009, 08:00:38 am »
The choice to delete will only appear for offline leases.

I suppose that could be changed, but that seemed the safest course of action.


Hmm, so if an active IP was deleted, and the user still had the DHCP address, i assume the DHCP server could possibly give out the same address to someone else, creating an IP conflict.

For troubleshooting purposes, it might be nice to be able to delete both, maybe a little note in the gui to explain deleting active leases.

When i can get the 1.2.3 release of this, i'll send over the bounty.

THANKS!

Offline jimp

  • Administrator
  • Hero Member
  • *****
  • Posts: 21404
  • Karma: +1437/-26
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #10 on: April 17, 2009, 08:18:12 am »
Hmm, so if an active IP was deleted, and the user still had the DHCP address, i assume the DHCP server could possibly give out the same address to someone else, creating an IP conflict.

For troubleshooting purposes, it might be nice to be able to delete both, maybe a little note in the gui to explain deleting active leases.

When i can get the 1.2.3 release of this, i'll send over the bounty.

THANKS!
Actually, the DHCP server should test (via ping I believe) if an IP is active before it hands out a lease. I haven't tested it, but I'm not sure what would happen if the host in question blocks ping.

I think there are supposed to be safeguards in place to ensure that it doesn't hand out conflicting IPs, but I'm not sure how robust they are, hence my erring on the side of caution.

Attached is a version of the file that allows deleting active leases, give it a go and see what happens.

This file has not changed between 1.2.2 and 1.2.3, so the same file will work on both.
Need help fast? Commercial Support!

Co-Author of pfSense: The Definitive Guide. - Check the Doc Wiki for FAQs.

Do not PM for help!

Offline djamp42

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +4/-0
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #11 on: April 17, 2009, 09:45:25 am »
It works great here, though i notice my client will receive the same IP, no matter how many times i delete the lease and do a renew on my client.

I was under the impression that dhcpd saves all DHCP leases given, so if a client leaves and returns a month later, he'll receive the same IP. I don't really mind that, but it would be nice if the delete button would make it, so the client receives another IP the next time he renews, (or the same ip by chance)


submicron

  • Guest
Re: DHCP Lease Delete Button - $30
« Reply #12 on: April 17, 2009, 09:49:12 am »
This would appear to be a complete bounty.  Has the bounty been paid so I can classify this as a completed bounty?

Offline Seth

  • Full Member
  • ***
  • Posts: 133
  • Karma: +3/-0
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #13 on: April 17, 2009, 09:50:16 am »
Your Windows client cant speak to other OSs will try and get the last IP that it had.

-Seth

Offline djamp42

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +4/-0
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #14 on: April 17, 2009, 10:06:12 am »
This would appear to be a complete bounty.  Has the bounty been paid so I can classify this as a completed bounty?

We are in the process now,  should be completed by the end of the day.

Offline djamp42

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +4/-0
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #15 on: April 17, 2009, 10:07:24 am »
Your Windows client cant speak to other OSs will try and get the last IP that it had.

-Seth

Ahhh so this is a feature of windows, rather then pfSense.

Thanks,
Adam

Offline jimp

  • Administrator
  • Hero Member
  • *****
  • Posts: 21404
  • Karma: +1437/-26
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #16 on: April 17, 2009, 11:07:15 am »
It should be complete now.

As Seth mentioned, a DHCP client can express a preference for an IP. It may not get it, but it can try.

I'm not sure, but you can try to see if forcing an "ifconfig /release *" then "ifconfig /renew *" from the command prompt will make it pull a new IP after deleting the lease.
Need help fast? Commercial Support!

Co-Author of pfSense: The Definitive Guide. - Check the Doc Wiki for FAQs.

Do not PM for help!

Offline djamp42

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +4/-0
    • View Profile
Re: DHCP Lease Delete Button - $30
« Reply #17 on: April 17, 2009, 11:36:50 am »
This is completed, please close thread

Offline sullrich

  • Hero Member
  • *****
  • Posts: 5110
  • Karma: +7/-2348
    • View Profile
    • pfSense
Re: DHCP Lease Delete Button - $30
« Reply #18 on: March 16, 2010, 04:46:13 pm »
This bounty has been completed and paid.  Thank you!
« Last Edit: April 01, 2010, 04:45:38 pm by sullrich »