-
-
Save tzarskyz/6746327 to your computer and use it in GitHub Desktop.
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 | |
# purpose: add a network location with manual IP info without switching | |
# This script lets you fill in settings and apply them on en0(assuming that's active) | |
# but only interrupts current connectivity long enough to apply the settings, | |
# it then immediately switches back. (It also assumes a 'Static' location doesn't already exist...) | |
# Use at your own risk! No warranty granted or implied! Tell us we're doing it rong on twitter! | |
# author: Allister Banks, 318 Inc. | |
# set -x | |
declare -xr networksetup="/usr/sbin/networksetup" | |
declare -xr MYIP="192.168.111.177" | |
declare -xr MYMASK="255.255.255.0" | |
declare -xr MYROUTER="192.168.111.1" | |
declare -xr DNSSERVERS="8.8.8.8 8.8.4.4" | |
declare -x PORTANDSERVICE=`$networksetup -listallhardwareports | awk '/en0/{print x};{x=$0}' | cut -d ' ' -f 3` | |
$networksetup -createlocation "Static" populate | |
$networksetup -switchtolocation "Static" | |
$networksetup -setmanual $PORTANDSERVICE $MYIP $MYMASK $MYROUTER | |
$networksetup -setdnsservers $PORTANDSERVICE $DNSSERVERS | |
$networksetup -switchtolocation Automatic | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment