Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dhcp: static lease config conflict with currently active leases #1026

Closed
3 tasks done
FlorianLudwig opened this issue Oct 5, 2019 · 11 comments
Closed
3 tasks done

dhcp: static lease config conflict with currently active leases #1026

FlorianLudwig opened this issue Oct 5, 2019 · 11 comments

Comments

@FlorianLudwig
Copy link

In raising this issue, I confirm the following: {please fill the checkboxes, e.g: [X]}

How familiar are you with the the source code relevant to this issue?:
1


Expected behaviour / Steps to reproduce:

  1. Added a device to the "Static DHCP leases configuration" with a different IP than the current lease
  2. Request new lease from said device
  3. Renew for existing leas should be denied and new lease with new IP forced

Actual behaviour:

Device remains old IP address.

Solution

  1. When adding a static lease config if an entry with same mac address exists delete it from/etc/pihole/dhcp.leases
  2. and/or allow user to delete leases allowing to work around the current situation via ui
@AzureMarker
Copy link
Contributor

This is dnsmasq's behavior for handling DHCP renewals and static leases. Please contact their mailing list to see what they can do. http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

@e28eta
Copy link

e28eta commented Dec 27, 2019

+1 for this, I'm setting up pihole for the first time, and this has been really frustrating to figure out.

I'd much rather the dynamic lease be automatically deleted when adding a static lease, but it looks like pi-hole/api#138 plus #177 would make this easier to manage?

@pralor-bot
Copy link

This issue has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/multiple-ip-addresses-in-network-overview/33562/18

@pralor-bot
Copy link

This issue has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/option-to-delete-existing-dhcp-reservation/34305/8

@afiaka87
Copy link

afiaka87 commented Jun 14, 2020

I think there's a failure to see this problem from the perspective of people who would like to use pi-hole's DHCP features and expect it to be mostly on par with whatever DHCP solution their router used to provide.

Case in point - my Netgear router has an option to add a static DHCP lease just like pi-hole does. When I add one, it instantly removes any leases attached to the MAC/ip combo and changes the ip address of the device right away.

It seems there's some legitimate pushback from the dnsmasq community on this issue. For them, it's a feature, not a bug.

For us, it's a bug, not a feature.

As such, I would think that the solution should probably be provided in pi-hole itself. I know maintainers have their hands full, but can we at least prioritize a native pi-hole solution to this problem rather than deferring people to go pester the dnsmasq community every time it comes up?

Thanks, and I'm happy to help with a solution although I'm weak on networking.

@afiaka87
Copy link

Ultimately I was able to look into the problem and found that it is indeed tough to solve due to universal lack of support for the FORCERENEW message by most clients. See here for more.

What I was able to do was halt pihole-FTL, remove the leases from /etc/pihole/dhcp.leases and then restart pihole-FTL. The problem here is that this alone doesn't magically tell all affected clients to update their IP address to the one specified in the static lease. They'll still try to connect to the IP given in the old lease.

The quickest way to fix that for me was by rebooting my router. Upon reconnecting to the internet most clients renegotiated their lease and connected to the correct static IP.

If you wanna try this yourself you can do so by:

# Make a copy of your leases in case you mess up
sudo cp /etc/pihole/dhcp.leases
# Stop the pihole-FTL service which manages DHCP
sudo service pihole-FTL stop
# Find the line containing the MAC and/or IP of the sticky lease in the 'dhcp.leases' file . Delete this line.
sudo nano /etc/pihole/dhcp.leases
# Start pihole-FTL back up
sudo service pihole-FTL start

At this point, the client in question will still be holding onto an old lease. If you have access to the device, and it is running linux, you can do this:

# DONT RUN ANY OF THIS ON YOUR PIHOLE, run it on the effected device if you can.
# Replace eth0 with the name of your clients interface e.g. wlan0
# This command releases the client's current DHCP lease.
sudo dhclient -r -4 -v eth0
# This command grabs the latest DHCP lease from the DHCP server (the pihole in our case)
sudo dhclient -4 -v eth0

That should do the trick for Linux devices. Other devices will need to be manually restarted, have airplane mode toggled, etc. In my case all clients happily renewed their leases when I rebooted my router. This is probably not a guarantee however.

@yubiuser
Copy link
Member

I think it is not necessary for most users to force a renewal of the lease to a client. I rather think it is sufficient what the OP suggested and let the users manually reconnect their devices to the network.

@pralor-bot
Copy link

This issue has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/v5-setting-static-ip-doesnt-work/34926/2

@pralor-bot
Copy link

This issue has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/remove-dhcp-leases-over-webgui/2277/23

@DL6ER
Copy link
Member

DL6ER commented Nov 24, 2020

@afiaka87 is right. These are technical limitation we cannot come across. With #1634 you can at least skip doing any manual work on the server as you can remove existing leases without the need for a server restart. The manual re-lease on the client is still needed and there isn't anything that could be done about it.

@yubiuser
Copy link
Member

This should be solved with #1634 and has been released by
https://discourse.pi-hole.net/t/pi-hole-core-web-v5-2-and-ftl-v5-3-released/40909

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants