-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path01-vlan.txt
99 lines (73 loc) · 2.74 KB
/
01-vlan.txt
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
***************************************************************************************************************
Linux-Bridge & VLAN to isolate tenant traffic
This method represents the "old" way of segregating tenant traffic – prior to the use of GRE/VXLAN tunnels
2 nodes required
****************************************************************************************************************
# On node1
# Create network namepsace for both companies
ip netns add mcdonalds
ip netns add burgerking
# Create veth pair for both companies
ip link add mdveth0 type veth peer name mdveth1
ip link add bkveth0 type veth peer name bkveth1
# Add veth1 to each company's namespace
ip link set mdveth1 netns mcdonalds
ip link set bkveth1 netns burgerking
# Add same ip to veth1 in both company's namespace
ip netns exec mcdonalds ifconfig mdveth1 10.0.0.5/24 up
ip netns exec burgerking ifconfig bkveth1 10.0.0.5/24 up
# Create a linux bridges for each company
brctl addbr br-md
brctl addbr br-bk
# Add veth pair to each company's linux bridge
brctl addif br-md mdveth0
brctl addif br-bk bkveth0
# Create vlan interface for each company (mcdonalds=10, burgerking=20)
ip link add link eth1 name eth1.10 type vlan id 10
ip link add link eth1 name eth1.20 type vlan id 20
# Add vlan interface to each company's bridge
brctl addif br-md eth1.10
brctl addif br-bk eth1.20
# Bring up the vlan interfaces
ip link set dev eth1.10 up
ip link set dev eth1.20 up
# Bring up the bridges
ip link set dev br-md up
ip link set dev br-bk up
# Bring up both veth0's
ip link set mdveth0 up
ip link set bkveth0 up
# On node#2
# Create network namepsace for both companies
ip netns add mcdonalds
ip netns add burgerking
# Create veth pair for both companies
ip link add mdveth0 type veth peer name mdveth1
ip link add bkveth0 type veth peer name bkveth1
# Add veth1 to each company's namespace
ip link set mdveth1 netns mcdonalds
ip link set bkveth1 netns burgerking
# Add same ip to veth1 in both company's namespace
ip netns exec mcdonalds ifconfig mdveth1 10.0.0.6/24 up
ip netns exec burgerking ifconfig bkveth1 10.0.0.6/24 up
# Create a linux-bridge for each company
brctl addbr br-md
brctl addbr br-bk
# Add veth pair to each company's linux-bridge
brctl addif br-md mdveth0
brctl addif br-bk bkveth0
# Create vlan interface for each company (mcdonalds=10, burgerking=20)
ip link add link eth1 name eth1.10 type vlan id 10
ip link add link eth1 name eth1.20 type vlan id 20
# Add vlan interface to each company's bridge
brctl addif br-md eth1.10
brctl addif br-bk eth1.20
# Bring up the vlan interfaces
ip link set dev eth1.10 up
ip link set dev eth1.20 up
# Bring up the bridges
ip link set dev br-md up
ip link set dev br-bk up
# Bring up both veth0's
ip link set mdveth0 up
ip link set bkveth0 up