Using Pi-Hole as DHCP Server - Disabling DHCP Server on Router Causes Problems

I'm running Pi-hole on a clean, single-purpose install of up-to-date Raspbian on a Pi 3B+. Everything was installed clean/fresh yesterday. I ran Pi-hole a number of years ago, but have done nothing since and I admit my skills/abilities have wasted.

Expected Behaviour:

Using all default settings, everything works fine.

I would like to use Pi-hole as my DHCP server, as using my router's DHCP server (Netgear XR500) causes all requests to show as originating from the router. I need to do this because my wife has several apps she insists on using which break when Pi-hole is enabled, so I need to be able to let specific devices through (which doesn't work when all requests show as originating from the router). I also like seeing the individual requests and stats per device.

I have enabled the DHCP server in Pi-hole, and set up all desired static DHCP leases. Up to this point, everything works fine. I would expect that at this point, disabling the DHCP server on the router would cause no issues.

Actual Behaviour:

As soon as I disable DHCP on the router, a couple things go wrong.

  1. I lose my ability to connect to the Internet from all connected devices.
  2. I lose my ability to connect to the Pi-hole web interface and via SSH, but I can still connect to my router.

Debug Token:

At this point, the DHCP server is enabled on both the Pi-hole and router, and things are working fine.
https://tricorder.pi-hole.net/PxTeDgsc/

Are you sure your Pi-hole has a static IP?

Your debug log shows Pi-hole IP is 192.168.0.3 and this IP was offered by your router.

   * Received 300 bytes from eth0:192.168.0.1
     Offered IP address: 192.168.0.3
     Server IP address: N/A
     Relay-agent IP address: N/A
     BOOTP server: (empty)
     BOOTP file: (empty)
     DHCP options:
      Message type: DHCPOFFER (2)
      server-identifier: 192.168.0.1
      lease-time: 86400 ( 1d )
      netmask: 255.255.255.0
      router: 192.168.0.1
      dns-server: 192.168.0.1
      --- end of options ---

A DHCP server needs a static IP (it cannot give an IP for itself).


Another question:

Did you renew the DHCP leases on your devices after switching DHCP server from router to Pi-hole?

Thanks for taking a look! From what I understand, reboots should renew DHCP leases. I didn't try every device, but I did reboot around 4 and had the same problem.

The IP settings shown confuse me. DHCP is set on both my router and the Pi-hole to assign the Raspberry Pi an address of 192.168.0.3, and the router is set to use 192.168.0.3 as the DNS server. It seems like that is probably the issue, but I'm at a loss for how to fix that.

Edit: If I'm understanding correctly, the Pi-hole DHCP server cannot assign the Raspberry Pi an IP address. That would be done by editing /etc/dhcpcd.conf, correct? As things currently stand, /etc/dhcpcd.conf is empty for me.

Exactly. A DHCP server can't assign an IP to its host machine.

That would depend on your OS and release.
The most recent Raspberry Pi OS 12 (Bookworm) uses NetworkManager, instead of dhcpcd in earlier versions.

If you instead would opt to rely on your router's DHCP server to assign an IP to your RPi hosting Pi-hole, you'd have to shrink its DHCP range to accommodate just your Pi-hole, and that very IP should not be part of your Pi-hole's DHCP range.

That would depend on your OS and release.
The most recent Raspberry Pi OS 12 (Bookworm) uses NetworkManager, instead of dhcpcd in earlier versions.

That would explain why editing /etc/dhcpcd.conf didn't work. I'll have to see what I can figure out for NetworkManager.

If you instead would opt to rely on your router's DHCP server to assign an IP to your RPi hosting Pi-hole, you'd have to shrink its DHCP range to accommodate just your Pi-hole, and that very IP should not be part of your Pi-hole's DHCP range.

If I did this, shrinking the range to just the Pi-hole, would the Pi-hole then serve as the DHCP server for all other devices? If so, this sounds much simpler.

I configured the network manager like this (setting statis IP to .29):
(Change IP's accordingly!!)
Interface names may vary depending on Your setup...

sudo nmcli c mod 'Wired connection 1' ipv4.addresses 192.168.0.29/24 ipv4.method manual
sudo nmcli con mod 'Wired connection 1' ipv4.gateway 192.168.0.1
sudo nmcli con mod 'Wired connection 1' ipv4.dns "8.8.8.8"
sudo sysctl -p
sudo nmcli c down 'Wired connection 1' && sudo nmcli c up 'Wired connection 1'

Note that last command will disconnect and change the IP!

There might be other ways but that worked for me...

You can also use sudo nmtui and get a ncurses menu to add / edit connections.

No, not quite.
Technically you'd still have two DHCP servers listening for your clients' DHCP broadcasts.
But if configured correctly, your router's DHCP server would only offer a DHCP lease to your Pi-hole machine, so all other clients would have no choice but to acquire their leases through Pi-hole's DHCP server.

In turn, this means if you cannot shrink your router's DHCP range to just one IP, then clients would be free to choose among the offers of both DHCP servers, and may pick up a lease from your router at times.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.