Pi-hole DHCP not allocating IP address

Please note that I am not a technical user at all. I followed the installation documents closely and I tried reading through other users that experienced DHCP issues, but haven't been able to get mine to work based on the feedback they received.

I set a static IP address for my Pi-hole using sudo nano /etc/dhcpcd.conf as 192.168.0.253, and the correct address is showing up in the router assigned to the Pi-hole itself. I chose to use Pi-hole as the DHCP server because my router can't set the DNS address. I disabled the router's DHCP server, rebooted it, and enabled Pi-hole's DHCP server. I've set up the following DHCP settings:
IP Range 192.168.0.2 to 192.168.0.252
Router IP: 192.168.0.1
I've enabled DHCPv4 and left IPv6 support unticked.
I set the lease time to 1 hour (at first I suspected the devices might hold on to the old IP, but I am planning to change that back to 24 hours)
While Windows devices are working fine, Android devices, Alexa and other Smart plugs can't obtain an IP address. I'm using a Raspberry Pi Zero 2 W with Raspberry Pi OS Lite.

When I set a static IP on my Android device its connecting without any issues.
I also removed the wifi network from my android device and reconnected it to the wifi, with no luck and still an error message Unable to obtain IP address.
My router model is ZTE MC801A.

Just after running the debug the following message also appeared in my Pi-hole diagnosis
Warning in dnsmasq core:
DHCP packet received on wlan0 which has no address.

Below is my debug token:
https://tricorder.pi-hole.net/numnE0ti/

Any help will be appreciated and thanks to the community and developers for this project.

The log file /var/log/pihole/pihole.log is showing that DHCP packets are coming in. You can see the DHCPDISCOVER come in over WLAN0 and then Pi-hole offering an address in reply to that request. The DHCP packets are correct:

*** [ DIAGNOSING ]: Discovering active DHCP servers (takes 10 seconds)
   Scanning all your interfaces for DHCP servers
   Timeout: 10 seconds
   
   * Received 300 bytes from wlan0:192.168.0.253
     Offered IP address: 192.168.0.95
     Server IP address: 192.168.0.253
     Relay-agent IP address: N/A
     BOOTP server: (empty)
     BOOTP file: (empty)
     DHCP options:
      Message type: DHCPOFFER (2)
      server-identifier: 192.168.0.253
      lease-time: 3600 ( 1h )
      renewal-time: 1800 ( 30m )
      rebinding-time: 3150 ( 52m 30s )
      netmask: 255.255.255.0
      broadcast: 192.168.0.255
      dns-server: 192.168.0.253
      domain-name: "lan"
      router: 192.168.0.1
      --- end of options ---
   
   DHCP packets received on interface wlan0: 1

There seem to be a few clients that are repeatedly trying to discover, are being offered an IP address but they never acknowledge the offer. I'm guessing those are the Android/Alexa devices. Do you have any lines in the file that tracks leases /etc/pihole/dhcp.leases?

Hi Dan.
Thanks so much for looking into this.
See below the lines when I ran /etc/pihole

$ cat dhcp.leases

1707774304 MAC1 192.168.0.100 * *
1707773865 MAC2 192.168.0.185 * 
1707774489 MAC3 192.168.0.126 SMARTHUB *
1707774380 MAC4 192.168.0.187 * *
1707774187 MAC5 192.168.0.200 PHONE
1707773661 MAC6 192.168.0.175 audiocast *
1707773667 MAC7 192.168.0.50 * *
1707773673 MAC8 192.168.0.235 TV 
1707773673 MAC9 192.168.0.195 Laptop 
1707773710 MAC10 192.168.0.43 * *
1707774503 MAC11 192.168.0.173 SMARTBULB *
1707774489 MAC12 192.168.0.119 SMARTPLUG *

I've removed the Mac addresses.
My phone is showing up in the list, but still giving an error message unable to obtain IP address.
I also have 4 smartplugs with only one showing up and the rest unable to connect. For the one smart plug that is connected I haven't done anything different than the other plugs.

If you look at /var/log/pihole/pihole.log you should see the DHCP traffic going on:

I see 3 clients that look like they are ignoring the OFFERs:

   Feb 12 08:06:36 dnsmasq-dhcp[12520]: DHCPDISCOVER(wlan0) 5c:REDACT:0d 
   Feb 12 08:06:36 dnsmasq-dhcp[12520]: DHCPOFFER(wlan0) 192.168.0.43 5c:REDACT:0d 
   Feb 12 08:06:36 dnsmasq-dhcp[12520]: DHCPDISCOVER(wlan0) 78:REDACT:bc 
   Feb 12 08:06:36 dnsmasq-dhcp[12520]: DHCPOFFER(wlan0) 192.168.0.126 78:REDACT:bc 
   Feb 12 08:06:36 dnsmasq-dhcp[12520]: DHCPDISCOVER(wlan0) 9c:REDACT:e9 
   Feb 12 08:06:36 dnsmasq-dhcp[12520]: DHCPOFFER(wlan0) 192.168.0.119 9c:REDACT:e9 

Those IP addresses do show up in your lease file.

Have you powered off the devices that are not working and rebooted them?

1 Like

I noticed that all three of those MACs seem to belong to TP-Link devices.

Are those interfaces of multiple devices, or just multiple interfaces of the same device?
What kind of device would they belong to?

Hi Dan,

I have rebooted all my devices and also tried the following this morning:

  • Turned off all devices
  • Reset the router to factory settings
  • Once the router was back online I disabled the router's DHCP server
  • Changed the SSID and password back to original values
  • Connected the Raspberry Pi first with its DHCP server active
  • Gradually rebooted other devices

While most smart plugs connected successfully, one remains unable to connect.

My Android phone and Alexa device are still unable to connect. I removed and re-added the Wi-Fi network on my phone but received an "Unable to obtain IP address" error. A static IP address works, but this isn't ideal for guests. The Alexa device also remains unconnected.

I ran another debug: https://tricorder.pi-hole.net/NV3jjg3g/

I looked at the /etc/pihole/dhcp.leases and there were multiple lines of ip addresses being offered over and over to the devices, but wasn't able to export it.

I hope this provides more information.

I am not the most technical person, so my apologies if I'm missing something.

Hi Bucking

These are multiple devices.
Its part of the Tapo range. Please see my response to Dan. Most of these have now reconnected with only one remaining unconnected.

Those would all be smart home devices then?

In any case, if one of them would be a router or switch, it may split your network into multiple segments/links.
As DHCP broadcasts are same-link only, devices connecting through such an additional router would not be able to reach a DHCP server on a different link, unless that router could be configured as a DHCP relay.

You could try to untick Enable DHCPv4 rapid commit in Pi-hole's DHCP settings and see if that would allow them to acquire a lease.

I unticked the Enable DHCPv4 rapid commit, but unfortunately no luck with getting an IP for my mobile devices and Alexa.
Also just to confirm all the TP link devices are smart home devices. None being a router or other network device. Also to add I don't have any Wi-Fi extenders etc. Just the main router.

Unfortunately I can't run the Pi Hole fully just yet and I mainly use my router and shut down the Pi Hole. Whenever I switch on my Pi Hole's DHCP server and switch off the routers DHCP server I get the below warning.
Could this be pointing to what is causing the issue?

I read up what I could a possible error could be if the pi hole doesn't have a valid IP address and I ran ifconfig wlan0. Below is the results (not sure if this helps)

How have you configured the static IP address for the Pi-hole WLAN0 interface?

I used the command sudo nano /etc/dhcpcd.conf in the terminal before installing Pi hole on my raspberry pi. I then rebooted the device before proceeding with the installation.
Please see below the configuration:
image

That should work for setting a static IP address, depending on which OS you are running.

Your debug log has expired, can you please show the version of the OS you are using? It can be found in /etc/os-release.

A recent change to the Raspberry Pi OS (Version 12) moved from dhcpcd5 to NetworkManager for IP addressing.

Hi Dan

See below

IMG-20240216-WA0003

1 Like

Raspbian 11 is the version that uses dhcpcd5.

The warning of no IP address happens when there really isn't an IP address on the interface. I remember Raspbian doing odd things with the WiFi interface and using power saving features to turn down the interface. This may be something related to that.

If you are going to have Pi-hole be your DHCP server then I strongly urge you to reconsider using WiFi as the network connection. It's possible to do but the reliability just isn't there.

Edit: Maybe this? Wifi disconnects after 6 hours on Raspian 11 (pi zero 2W) - Raspberry Pi Stack Exchange

Hi Dan

I checked the power savings for wlan0 and it was enabled by default. Changing this did not solve the issue though.

After disabling the power savings and rebooting the Pi I still encountered the same problem where my smart plugs, Alexa and Android devices aren't able to obtain an IP address.

Could it be my router that doesn't work well with another DHCP server and is there a way to test this like downloading another DHCP service to see if I experience the same issue or could it be that I'm using wlan instead of ethernet?
(I do not have a micro USB to ethernet adaptor. I'm happy to purchase this if it might solve the issue, but would just like to rule out other issues before going ahead).

For the time being I've set a static IP and DNS (using the raspberry Pi IP address) for each device I could.

Hi Dan.

I just wanted to confirm that I have resolved the issue.
Using Pi Hole as the DHCP server over WiFi was the problem.

I bought a compatible Micro USB to ethernet adaptor, redone the installation and everything is working without any issues.
(I noticed one of the micro USB ports are for power only and one can handle data and power so be sure to try both if it doesn't seem to be working).

Thanks for coming back to give us the resolution!