Created
March 31, 2015 18:59
-
-
Save chuckg/c2c18a9177e4ec70803c to your computer and use it in GitHub Desktop.
Unfuck your Mac's networking after using VPN, changing WIFI, etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo networksetup -setv4off Wi-Fi | |
sleep 1 | |
sudo networksetup -setv6off Wi-Fi | |
sleep 1 | |
sudo networksetup -setdhcp Wi-Fi | |
sleep 1 | |
sudo networksetup -setv6automatic Wi-Fi | |
sleep 1 | |
# Clear DNS | |
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist | |
sleep 1 | |
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
IFS=$'\n' | |
for i in `networksetup -listallhardwareports | awk -F": " '/Hardware Port/ { print $2 }'`; do | |
echo "Fix $i" | |
networksetup -setv4off $i > /dev/null 2>&1 | |
if [ "$?" = "0" ]; then | |
sleep 1 | |
networksetup -setdhcp $i | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment