Skip to content

Instantly share code, notes, and snippets.

@shichao-an
Last active February 25, 2016 06:26
Show Gist options
  • Save shichao-an/5be6baa2c6ebc2191ad7 to your computer and use it in GitHub Desktop.
Save shichao-an/5be6baa2c6ebc2191ad7 to your computer and use it in GitHub Desktop.
Personal Hotspot Backup Plan (OS X)
#!/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"
#!/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