MacOS – How to fix DNS resolving issues on Mountain Lion after waking from sleep

dnsmacossleep-wake

After I installed Mountain Lion the other day I've noticed something very annoying. Almost every time I wake my iMac (27", mid-2010, CI7) from sleep: it seems that something DNS-related is broken. When I try connecting to other machines using their IP (v4 & v6) addresses I can SSH and send pings, but resolving host names isn't working very well.

Now I have not yet tried checking my DNS server logs to see if the requests are even making it there. Though I suspect that the DNS request are not making it to the DNS server since a quick reboot of the client machine or using another client machine works ok.

I've seen a couple of mentions of similar problems on other sites but no credible answers to why this problem appears, one user who was using WiFi apparently "fixed" it by toggling some random seemingly unrelated WiFi and sleep settings which just makes me suspect that this issue is some setting that got broken.

I'd love to find a reliable workaround/solution to this problem but I've double-checked all settings in the power management and network preference panes and it all looks fine. I have also tried re-saving the settings after making some changes and then reverting to the original settings just to see if that fixed it for me as well, no such luck. How to fix DNS resolving after wake from sleep?

Edit: I am only using wired networking myself and wifi is completely turned off. Both IPv4 and IPv6 settings have been made manually.

The network is a plain old 192.168.1.0/24 subnet with all machines connected to a fairly cheap managed gigE switch, 100/100 Mbps FTTH connection that goes to a FreeBSD box which acts as the gateway, dhcp (isc-dhcp for 192.168.1.1-72) and DNS (bind) server. IPv6 connectivity is through a Sixxs tunnel. Pretty standard setup that hasn't caused any problems in the past.

Best Answer

I've had this exact same experience, though not every time. Sometimes it means sites that I have visited recently are unavailable but other sites I haven't visited in ages load just fine.

Usually flushing the DNS cache resolves it.

sudo killall -HUP mDNSResponder