Skip to content

Instantly share code, notes, and snippets.

@dlutcat
Created September 18, 2012 13:17
Show Gist options
  • Save dlutcat/3743043 to your computer and use it in GitHub Desktop.
Save dlutcat/3743043 to your computer and use it in GitHub Desktop.
Auto switch network config between home and office.
#!/bin/sh
# happyhouse is my home wifi name
happyhouse=`airport -s | grep happyhouse | wc -l`
if [ "${happyhouse//[[:space:]]}" = '1' ]; then
networksetup -setmanual wi-fi 192.168.2.129 255.255.255.0 192.168.2.1
networksetup -setdnsservers wi-fi 192.168.2.1
fi
if [ "${happyhouse//[[:space:]]}" = '0' ]; then
networksetup -setmanual wi-fi 192.168.0.129 255.255.255.0 192.168.0.1
networksetup -setdnsservers wi-fi 192.168.0.1
fi
#networksetup -getinfo wi-fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment