-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-bridge.sh
executable file
·47 lines (29 loc) · 1.21 KB
/
setup-bridge.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
45
46
47
#!/bin/sh
# install docker
apt install docker.io -y
apt install iproute2 -y
apt install net-tools -y
apt install jq -y
# create new docker bridge network
# "--opt com.docker.network.driver.mtu=8950" ensures any new containers on bridge will automatically configure interface MTUs
echo ~~~Creating docker bridge network~~~
docker network create --opt com.docker.network.driver.mtu=8950 --subnet 172.18.0.0/16 vxlan-bridge
bridge_id=$(sudo docker network inspect -f {{.Id}} vxlan-bridge)
# create VXLAN tunnel interface
echo ~~~Creating VXLAN tunnel interface~~~
# "vxlan-tunnel" - arbitrary interface name
# "type vxlan" - interface type
# "id 100" - VNI (VXLAN Network Idenfitifer)
# "remote 213.173.111.95" - target host machine
# "dstport 4789" - standard UDP port over VXLAN
# "dev bond0" - find default host interface with "ip route"
ip link add vxlan-tunnel type vxlan id 100 remote 213.173.111.94 dstport 4789 dev bond0.2636
# set interface to "UP"
ip link set vxlan-tunnel up
# show new interface
ip a | grep vxlan-tunnel
# attach new VXLAN-tunnel interface to our docker bridge network
echo ~~~Attaching VXLAN tunnel to docker bridge~~~
brctl addif br-${bridge_id} vxlan-tunnel
# show bridge interfaces
brctl show