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.
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?
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.
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 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.
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.
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)
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:
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.
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.
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).