forked from akoshibe/ecord-topos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ovs_vxlan.sh
executable file
·44 lines (36 loc) · 971 Bytes
/
ovs_vxlan.sh
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
#!/bin/bash
# usage:
# ./ovs_vxlan.sh add <interface> <vlan_vid> <vxlan_vni> <vxlan_remote_ip> <vxlan_local_ip>
# ./ovs_vxlan.sh delete <interface> <vlan_vid> <vxlan_vni>
CMD=$1
IF=$2
VID=$3
VNI=$4
REMOTE_IP=$5
LOCAL_IP=$6
function add_config() {
IF=$1
VID=$2
VNI=$3
REMOTE_IP=$4
LOCAL_IP=$5
sudo vconfig add $IF $VID
sudo ip link set $IF.$VID promisc on
sudo ovs-vsctl add-br ovs$VID
sudo ovs-vsctl add-port ovs$VID $IF.$VID
sudo ovs-vsctl add-port ovs$VID vxlan$VNI -- set interface vxlan$VNI type=vxlan options:key=$VNI options:remote_ip=$REMOTE_IP options:local_ip=$LOCAL_IP
}
function delete_config() {
IF=$1
VID=$2
VNI=$3
sudo ovs-vsctl del-port vxlan$VNI
sudo ovs-vsctl del-port $IF.$VID
sudo ovs-vsctl del-br ovs$VID
sudo vconfig rem $IF.$VID
}
if [ $CMD = "add" ]; then
add_config $IF $VID $VNI $REMOTE_IP $LOCAL_IP
elif [ $CMD = "delete" ]; then
delete_config $IF $VID $VNI
fi