Only a few times I lost my network since August where I did the SMC resets etc.
Anyway, Thanks to Bernhard de Baehr it is fairly easy to make a function to Down/Up interfaces using sleepwatcher 2.2 which you can download from http://www.bernhard-baehr.de/
I choosed system wide, so my commands are for system wide
1. Download SleepWatcher_2.2 to Desktop
2. Dbl. click to unzip, a SleepWatcher 2.2 folder is created in desktop
3. Open ReadMe.rtf and follow "Installation for new SleepWatcher users" using Terminal Window
Comments on steps in ReadMe.rtf:
Step 3:
With vi or your favorite editor create .sleep and .wakeup scripts with actions in your home folder /Users/<username>
For this problem I only use .wakeup with the follwing content, omit ---------------------------------- lines
----------------------------------
#!/bin/sh
#Used by sleepwatcher to do stuff on wakeup
#Called from /etc/rc.wakeup
#Edit GW, LIF and WIF as needed.
#Gateway to test
GW=192.168.1.1
#LAN IP and Interface information
LIF=en0
#WIFI IP and Interface information
#WIF=en1
#Down and Up LAN interface if GW is unavailable through $LIF
if [ "$LIF" != "" ] && [ $(ping -b $LIF -t 1 -c 4 $GW 2>&1|grep -c "100.0% packet loss") != 0 ]; then
ifconfig $LIF down
sleep 1
ifconfig $LIF up
logger "wakeup: $LIF re-cycled"
fi
#Down and Up WIFI interface if GW is unavailable through $WIF
if [ "$WIF" != "" ] && [ $(ping -b $WIF -t 1 -c 4 $GW 2>&1|grep -c "100.0% packet
loss") != 0 ]; then
ifconfig $WIF down
sleep 1
ifconfig $WIF up
logger "wakeup: $WIF re-cycled"
fi
#Other stuff to follow
-----------------------------------
Change permission
chmod 750 .sleep
chmod 750 .wakeup
Step 5: I skipped this because file copied in Step 6 and permanent load is done with -w in Step 7
Step 6:
sudo cp Desktop/sleepwatcher_2.2/config/de.bernhard-baehr.sleepwatcher-20compatibility. plist /Library/LaunchDaemons/
chmod 644 /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher-20compatibility.plist
sudo cp Desktop/sleepwatcher_2.2/config/rc.* /etc
sudo chmod 750 /etc/rc.sleep
sudo chmod 750 /etc/rc.wakeup
There is a extented attribute "com.apple.quarantine" on the config files, remove with
sudo xattr -d com.apple.quarantine /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher-20compatibility.plist
sudo xattr -d com.apple.quarantine /etc/rc.wakeup
sudo xattr -d com.apple.quarantine /etc/rc.sleep
Step 7:
sudo launchctl load -w /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher-20compatibility.plist
4.Test
reboot
from Terminal do
sudo launchctl list | grep sleepwatcher and check that "de.bernhard-baehr.sleepwatcher" is running
tail -f /var/log/system.log | grep wakeup
sleep/wake a few times and watch for wakeup entries in system.log
if ping succeeds in .wakeup there are no wakeup entries
All set 🙂