Created
April 3, 2014 02:07
-
-
Save samos123/9947072 to your computer and use it in GitHub Desktop.
Playing around with bash, at the university I have to manually set my internet configuration on a specific network. Thought let's automate it
This file contains hidden or 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 | |
set -xi | |
sudo ip addr add 172.16.4.99/22 dev eth0 | |
GATEWAY=$(ip route show | grep default | awk '{ print $3}') | |
echo "Current default gateway: $GATEWAY" | |
if [ -z $GATEWAY ] | |
then | |
sudo ip route del default $GATEWAY | |
fi | |
sudo ip route add default via 172.16.4.1 | |
echo "nameserver 166.111.8.28" | sudo tee -a /etc/resolv.conf | |
echo "Done.." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment