RaspberryPi Loses IPv4 address as soon as router DHCP is disabled

Raspberry Pi 4 has Pi-hole installed as its only application. Connected to Netgear router via ethernet. Static IP is set in router DHCP and Pi-hole DHCP.

Expected Behaviour:

Pi-hole should be handling DHCP with it enabled in admin interface, and disabled on router.

Actual Behaviour:

As soon as router DHCP is disabled, the Pi loses its IPv4 address, and is no longer accessible via admin console. I can still SSH in. When I turn the router DHCP back on, I can get in again, and I see this DNSMASQ error in the admin interface: DHCP packet received on eth0 which has no address. In fact, no devices are able to get an address, they do not see any DHCP servers on the network.

This configuration has worked well for me in the past, the Pihole DHCP would start picking up clients easily, but after resetting my router recently, I have not been able to enable Pihole's DHCP at all.

I assume this all stems from the fact that the Pi's IP address completely goes away, as it is not visible on the network to give out addresses.

If you can still SSH in then it still has its IP address. It looks like the problem is that your router DHCP and Pi-hole DHCP are both active at the same time and are treading on each other's toes, so to speak, each giving out their version of the network, and you have clients that have touched both versions on the network at the same time, so the same conflicts are arising each time.

Would you be open to trying to use just the Pi-hole and doing a clean start with every device on the network? It just means doing a bit of config and then disconnecting and reconnecting every device, and after that it will be hopefully okay, since everything will have come from just the one Pi-hole DHCP server.

To use just the Pi-hole, set the Pi-hole's DHCP range from, say, 192.168.1.20 to 192.168.1.254 and Save the changes. Starting at .20 means you have the space from .2 to .19 for static IP usage, such as the Pi-hole itself, which is very useful.

Then open a terminal on the Pi-hole and enter pihole -r and select Reconfigure (you won't lose any adlists or domain settings during this process). When asked for the static IP address, enter 192.168.1.2 (or something in that unused region below .20). The syntax used is 192.168.1.2/24, where the /24 is the correct way of describing this network. Finish up the settings and get ready to reboot it.

First though, log in to your router and disable the DHCP server and save the changes.

Now reboot the Pi-hole and let it come back up.

Finally, go to each device on the network and toggle its wifi off and on or unplug/replug its ethernet cable, or reboot it if that's easier. That will let them all pick up a new, clean address from the Pi-hole. You will see the devices picking up addresses when you refresh the Pi-hole's DHCP page.

You may see an occasional IP conflict warning, before all devices have been reconnected, if one of them has an old address from the router's DHCP. Once it's reconnected it will pick up a new address from the Pi-hole DHCP and the conflict will be fixed.

Does that fix everything and make it all behave?

Thank you for your reply. Here are the steps I followed exactly:

Removed all devices from network except router, Raspberry Pi, and the MacBook I’m working from.

Both router and pihole dhcp’s are running to start

  1. Set the Pihole DHCP range from 20 to 254, saved changes
  2. Ran pihole -r, it didn’t ask me to set a static IP, it just told me to use the IP it already has (192.168.1.6)
  3. Double checked that IP is set to static in router
  4. Turned off router DHCP, laptop loses internet (gets self assigned IP)
  5. Used SSH to reboot Raspberry Pi, it comes back up

Now here is where things don’t seem to be working:

  1. Enabled WiFi on laptop (using a windows laptop now since I know it a little better)

  2. It gets self assigned IP, no internet access, I can ping the router, but not the pihole

  3. If I manually set DNS to 8.8.8.8 for the laptop, I get internet access, but still can’t ping pihole

  4. Running ipconfig /renew throws “can’t find DHCP server error”

  5. I can only SSH into the Pihole after manually setting DNS on laptop to 8.8.8.8

  6. Running hostname -I returns a blank line

  7. Router no longer sees pihole connected to it via its admin interface, it gave my two laptops IP addresses despite DHCP being off

  8. Tried ipconfig /renew on laptop again, still getting no DHCP server error, but ipconfig /all does see the Pihole as the DHCP server, but I still can’t ping the pihole’s address

I know you mentioned that it should have an IP address if I can SSH in, but I can only SSH in using the .local hostname

As I’ve searched for solutions, a lot of posts have mentioned messing with /etc/dhcpcd.conf, or restarting the dhcpcb service. That .conf file does not exist on my pihole at all, this is a brand new fresh installation.

Did you set a static IP on the Pi4 (not the same as a static DHCP reservation)?
Thats a requirement for the DHCP service to work on the Pi4.

The Pi-hole DHCP service cant assign itself an IP address bc for that, the Pi-hole host (Pi4) already needs to have an IP to transition to unicast (IP to IP) for the DORA transaction to complete.
And a static DHCP reservation for the Pi4 on the router wont work if you disable the router DHCP service.

I just did a fresh installation of Raspbian headless, and Pihole itself. The dhcpcd.conf file doesn’t exist in /etc/, sorry for being dense but am I missing something during the initial installation? Or should I be manually installing dhcpcd5?

Do you have the Raspbian/Pi-OS desktop or the lite version installed?
I believe the desktop runs network-manager to manage connections/IP etc.

Below allows you to set static IP details for that:

sudo nmtui

Missed the headless bit :wink:

Could try as I havent installed Bookworm yet:

sudo nmtui

Amazing. This worked perfectly as far as I can tell so far. You're the first person I've seen mention nmtui. I went in there and was able to set the IP manually. Thanks!

1 Like

network manager text user interface

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