-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdown.sh
More file actions
executable file
·47 lines (40 loc) · 1.14 KB
/
down.sh
File metadata and controls
executable file
·47 lines (40 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
if [ "$(id -u)" != "0" ] ;
then echo -e "\e[31m Please run as root!\033[0m"
exit 126
fi
function check_error {
if [ $? -ne "0" ] ;
then echo -e "\e[31mError!\033[0m"
exit 126
fi
}
function reset_ovs {
NIC="eth0"
IP=$(ip addr show br-ext | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
GW=$(ip route | grep default | awk '{print $3}')
MAC=$(ifconfig br-ext | grep "HWaddr\b" | awk '{print $5}')
MASK=$(ip addr show br-ext | grep "inet\b" | awk '{print $2}' | cut -d/ -f2)
echo -ne "Giving the physical interface an IP...\t\t\t\t\t"
ifconfig $NIC $IP/$MASK > /dev/null 2>&1
check_error
echo "Done!"
echo -ne "Changhing physical interface MAC adress...\t\t\t\t"
ifconfig $NIC down
check_error
ifconfig $NIC hw ether $MAC
check_error
ifconfig $NIC up
check_error
echo "Done!"
echo -ne "Removing the OpenvSwitch bridge...\t\t\t\t\t"
ovs-vsctl del-br br-ext
check_error
echo "Done!"
echo -ne "Routing traffic through the physical interface...\t\t\t"
while $(ip route del default > /dev/null 2>&1); do :; done
ip route add default via $GW dev $NIC
check_error
echo "Done!"
}
reset_ovs