Fixing a WiFi (actually DHCP) issue on my Mac
In general over the years, my Macs have just worked. I've seen none of the weird behavior with them that I have with Windows. However last week I encountered something new.
On startup or login, I would see the WiFi indicator pulse as it tried to get an IP address from my local DHCP server. After the requisite 30 seconds it would give up and the WiFi icon would get the ! overlay indicating it had self-assigned an IP from the 169 range. All the other devices in my house had no trouble getting an IP address. If I tethered my Mac to my iPhone or iPad, it would pull an IP without any trouble. Furthermore, I also have a wired ethernet adapter on this machine and it could not get an IP either. If I assigned an IP manually to either device, network traffic would flow normally, so I knew that the WiFi was successfully associating to the AP and the wired ethernet was passing traffic as well.
I first suspected my network, but all the other devices didn't have any trouble. Logs for my DHCP server showed DHCPREQUEST from the Mac and DHCPOFFER from the DHCP server, but no DHCPACKs.
I tried the following:
Removing the WiFi network entry from the list of known SSIDs and re-associating the Mac with the SSID (required re-entering the WiFi password)
Manually assigning an IP address to the WiFi's MAC address in my DHCP server.
Creating a new "Network Location" in the Network control panel.
Restarting the machine, as well as powering off the machine fully and doing a cold boot.
Manually removing the IP address leases for my Mac from the lease database on my DHCP server.
I did not try turning off the macOS Firewall, as this is a machine managed by my work, and they have that setting locked.
What did finally work was to create a new administrator account and login to that account. At that point both the wireless and wired devices could pull an IP over DHCP. DHCP continued to work after restarting and logging into my original account.
My guess is one or more of the files macOS uses to keep track of network status had become corrupted such that the Mac would never accept a DHCP offered IP, but only for my network (which is in the 172 block). I wish I knew where those files were, as there doesn't seem to be an easier way for them to get rewritten.