Your MacOS won’t get IP address from DHCP server? – jozefmares.com
Home top_menu_hacks Your MacOS won’t get IP address from DHCP server?

Your MacOS won’t get IP address from DHCP server?

by Jozef Mares

Encountering a DHCP error on your Mac can be a frustrating experience, as I know from personal experience. I spent several Saturday hours trying to debug issues with my network. In this article, we’ll go over some common reasons why you might not be getting an IP address from your DHCP server on macOS, and how you can troubleshoot and fix the issue.

The symptoms of the problem typically involve your Mac using a self-assigned IP address instead of obtaining one from the DHCP server. I initially thought that the issue might be with my network setup, which includes a gateway device (based on Turris Omnia), VLANs, firewalling, a switch, and a dedicated AP connected to the switch. There are many moving parts in such a setup, so there were plenty of opportunities for things to go wrong.

To diagnose the issue, I checked the logs on the gateway device and found repeating messages indicating that DHCP offers were being sent but no DHCP requests were being received.

Apr 2 13:04:23 gw dnsmasq-dhcp[5085]: DHCPDISCOVER(lan0.150) --REDACTED_MAC--
Apr 2 13:04:23 gw dnsmasq-dhcp[5085]: DHCPOFFER(lan0.150) --REDACTED_IP-- --REDACTED_MAC--.

I used TCPdump to capture the traffic and confirmed that there were no DHCP requests being sent by my Mac.

tcpdump -i lan0.150 port 67 or port 68

13:34:55.138920 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from --REDACTED_MAC-- (oui Unknown), length 300
13:34:55.139467 IP 192.168.150.1.67 > 192.168.150.3.68: BOOTP/DHCP, Reply, length 311
13:35:03.421299 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from --REDACTED_MAC-- (oui Unknown), length 300

Just for the unitiated, here is how proper DHCP communication looks like:

CLIENT -> DHCPDISCOVER
SERVER -> DHCPOFFER
CLIENT -> DHCPREQUEST
SERVER -> DHCPACK

Manually setting the IP address confirmed that the network was working, which meant that the issue was with macOS.

Further investigation using the Console app revealed an error log related to DHCP, indicating that my Mac was stuck in the “INIT waiting” state.

DHCP en0: INIT waiting at 4 for 4.107551

After searching online (for example here or here, I found similar issues reported by other users, which led me to suspect that the network cache on my Mac was corrupted. But before that I fiddled for another two hours with networking because I ignored info I already found. :)

One common cause of DHCP issues on macOS is a corrupted network cache. This can occur due to outdated or conflicting network configurations, previous network connections that were not properly closed, or a malfunctioning network daemon. To troubleshoot this issue, you can try resetting your network configuration and cache by running the following commands in Terminal:

sudo dscacheutil -flushcache 
sudo killall -HUP mDNSResponder

If resetting the network configuration doesn’t work, you can try updating your macOS to the latest version, which may include bug fixes related to networking.

In my case, I had an update pending, so I triggered it and rebooted my Mac. After the update, everything worked correctly. I assume that there was something wrong with the network daemon, and the update triggered a cache flush, which resolved the issue.

In conclusion, encountering a DHCP error on macOS can be frustrating, but with a little troubleshooting, you can usually fix the issue. Remember to check your network configuration, reset your network cache, and update your macOS to the latest version. If all else fails, booting into single-user mode can help you diagnose the issue further.

You may also like