Last active
February 25, 2016 06:26
-
-
Save shichao-an/5be6baa2c6ebc2191ad7 to your computer and use it in GitHub Desktop.
Personal Hotspot Backup Plan (OS X)
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
#!/usr/bin/env bash | |
# After disconnecting from the iPhone Hotspot, run this command | |
OLD_DEFAULT_ROUTE="10.0.1.1" | |
# Turn off WiFi | |
networksetup -setairportpower en0 off | |
# Flush all routes | |
sudo route flush | |
# Add the new default route | |
sudo route -n add default "$OLD_DEFAULT_ROUTE" |
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
#!/usr/bin/env bash | |
set -e | |
# After connecting to the iPhone Hotspot, run this command | |
NEW_DEFAULT_ROUTE="172.20.10.1" | |
HOTSPOT_SSID="ASC-IPHONE6" | |
echo "Please turn on the iPhone Hotspot $HOTSPOT_SSID." | |
sleep 5 | |
# Turn on WiFi and connect to Hotspot | |
networksetup -setairportpower en0 on | |
networksetup -setairportnetwork en1 "$HOTSPOT_SSID" 'wifipassword' | |
sleep 5 | |
# Flush all routes | |
sudo route flush | |
# Add the new default route | |
sudo route -n add default "$NEW_DEFAULT_ROUTE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment