Last active
October 26, 2015 11:02
-
-
Save sloev/5435400e42cc0eea3bb6 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 | |
# | |
# Network configuration for basic server | |
# using '/bin/ip' | |
# | |
# Note: hostname and the lo interface are | |
# set up by boot.localnet | |
# | |
ip="/bin/ip" | |
dev=eth0 | |
myIP="192.168.149.XX/25" | |
# For XX refer to the note "Server IP Addresses" | |
router="192.168.149.1" | |
# | |
case "$1" in | |
start) | |
echo "Starting the network" | |
# | |
# 1. The ethernet interface | |
# | |
$ip link set up dev $dev | |
$ip addr add $myIP dev $dev brd + | |
# | |
# 2. The default gateway | |
# | |
$ip route add default dev $dev via $router scope global | |
;; | |
stop) | |
echo "Stopping the network" | |
$ip route del default | |
$ip addr del $myIP dev $dev | |
$ip link set down dev $dev | |
;; | |
restart) | |
# stop the network and start it again | |
$0 stop | |
$0 start | |
;; | |
*) | |
echo "Usage $0 [start|stop|restart]" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment