Skip to content
accelerando

Mac OS X Lion loses network connection after sleep

Sleep related problems have never been a problem for me with OS X (at least the sleep of the machine) since Lion.

Sleep works perfectly fine but after wake my machine has no internet connection anymore, at least it looks like this. It’s only domains that aren’t resolved anymore. It also affects wired and wifi networks. There are a lot of threads in the Apple forums that blame USB drives, Optical drives and the like but this sounds a bit like voodoo.

I found the following working solution:

Edit “/System/Library/LaunchDaemons/com.apple.mDNSResponder.plist” like so:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>com.apple.mDNSResponder</string>
	<key>OnDemand</key>
	<false/>
	<key>UserName</key>
	<string>_mdnsresponder</string>
	<key>GroupName</key>
	<string>_mdnsresponder</string>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/sbin/mDNSResponder</string>
		<string>-launchd</string>
		<string>-AlwaysAppendSearchDomains</string>
		<string>-DisableSleepProxyClient</string>		
	</array>
	<key>MachServices</key>
	<dict>
		<key>com.apple.mDNSResponder</key>
		<true/>
	</dict>
	<key>Sockets</key>
	<dict>
		<key>Listeners</key>
		<dict>
			<key>SockFamily</key>
			<string>Unix</string>
			<key>SockPathName</key>
			<string>/var/run/mDNSResponder</string>
			<key>SockPathMode</key>
			<integer>438</integer>
		</dict>
	</dict>
	<key>EnableTransactions</key>
	<true/>
</dict>
</plist>

and relaunch the mDNSResponder like so:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist 
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

This fixes to things: The domain resolution described here and the 2 hourly automatic wake from sleep described here.

Update:

It seems that fixed the problem just for that one time. To fix it every wake i use “SleepWatcher” by . Installed as said in the read me, save this file somewhere as restart_mDNSResponder

#!/bin/bash
killall -HUP mDNSResponder

and copy this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>de.bernhard-baehr.sleepwatcher</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/local/sbin/sleepwatcher</string>
                <string>-V</string>
                <string>-w /path/to/restart_mDNSResponder</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>KeepAlive</key>
        <true/>
</dict>
</plist>

to /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher-20compatibility.plist.

and execute

sudo launchctl load -w /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher-20compatibility.plist

This did the trick for me.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

*

Close
E-mail It