pi-hole / web

Pi-hole Dashboard for stats and more
https://pi-hole.net
Other
2.02k stars 561 forks source link

DHCP server ignores static leases #2546

Closed sargonphin closed 11 months ago

sargonphin commented 1 year ago

Versions

Platform

Expected behavior

Following a new connection from a new device, the new device gets an address from the DHCP pool. In Pi Hole Web configuration panel, after assigning a static lease, a DHCP renew on the new device (release + request) should fail with a NAK response from the DHCP server, offering the address defined in the static lease instead.

Actual behavior / bug

The server bypasses the static leases, uses existing leases saved in database and acknowledges the request from the new device, which ends up getting the same DHCP pool address as before instead of the static lease IP.

In Pi Hole Web configuration panel, deleting the lease (before or after disconnecting the new device) makes no difference.

Restarting the PiHole FTL service seems to be a workaround. The issue fixes itself after the initial DHCP pool lease has expired.

Steps to reproduce

Steps to reproduce the behavior:

  1. Connect a new, unknown device to the network using DHCP autoconfiguration. The device gets a DHCP pool address.
  2. Setup a static lease in the DHCP server configuration panel using an IP outside of the DHCP pool
  3. Disconnect and reconnect the new device to the network (or request a new DHCP lease)
  4. Refresh the DHCP server configuration panel or lookup the new IP in the new device
  5. The IP is the same as the previously delivered DHCP pool address
dschaper commented 1 year ago

Debug token URL as requested in the template please.

DL6ER commented 1 year ago

This is expected and should also be documented somewhere: Static DHCP leases are configured using dhcp-host config options for the dnsmasq server which re-reads its full config only during a restart (some parts like changing /etc/hosts files can be done at runtime, but this is rather an exception). As you reported that restarting pihole-FTL solves the issue, I truly think there is no issue at even begin with. The "workaround" you describe is what is really happening, expected and designed to work like this.

DL6ER commented 1 year ago

I'm going to close this as I see no bug here. If you still think there is one, feel free to comment + reopen at any point.

sargonphin commented 1 year ago

Hello! Really really sorry I didn't add the debug link and took so much time to reply... I was super duper busy!

I understand the inner workings now and why it is not behaving as I would like. I suggest to prompt to restart the FTL service on the configuration page every time a static lease is added, or at least have a warning stating that the changes will only take effect upon restarting the service.

It is not mentionned anywhere clearly, sadly :( I think this could be improved

DL6ER commented 1 year ago

Moving as this is a question for the web interface.

yubiuser commented 1 year ago

Currently working on a note to the web interface for this.

sargonphin commented 1 year ago

Really cool, thank you a lot :) A button to restart the service directly from the UI would be the best, is it possible?

yubiuser commented 1 year ago

Go to Settings > System > Restart Resolver

sargonphin commented 1 year ago

Thanks for the tip :D If that's possible, could it be added as a direct access button when changing DHCP settings? In the same place as the warning about the DHCP changes?

yubiuser commented 1 year ago

No, I wouldn't do that. It fits well in System and there are other reasons as to restart the resolver than DHCP. I think you can effort an additional click.

sargonphin commented 1 year ago

Oh I did not meant to move it to the DHCP settings! What I meant was to put a link/button to restart the resolver on the same warning window that will say that DHCP changes requires a resolver restart :) basically, a duplicate ^_^

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.

keawade commented 1 year ago

Hey, can we reopen this issue, please?

I've run into this a couple times now and it's been quite frustrating. The note suggested would go long way to help myself and other users avoid this confusion in the future. :)

github-actions[bot] commented 11 months ago

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.