Quantcast
Channel: 钻戒 and 仁豆米
Viewing all articles
Browse latest Browse all 290

Open vSwitch组成 Vxlan跨越物理机的方法

$
0
0

其实Open vSwitch组Vxlan的方法跟设置GRE/patch port的方法差不多的:

基本场景:

  • 物理机HostA 网卡eth0 的 IP 是172.16.8.105
  • 物理机HostB 网卡eth0 的 IP 是172.16.8.106

创建网桥:

# HostA
ovs-vsctl add-br br0  
ovs-vsctl add-port br0 eth0  
ifconfig eth0 0  
ip a add 172.16.8.105 dev br0  
ip link set br0 up

# HostB
ovs-vsctl add-br br0  
ovs-vsctl add-port br0 eth0  
ifconfig eth0 0  
ip a add 172.16.8.106 dev br0  
ip link set br0 up  

增加netns命名空间

# HostA 和 HostB
ip netns add ns1  

创建内部端口

# HostA 和 HostB
ovs-vsctl add-port br0 tap1 -- set Interface tap1 type=internal  

设置命令空间

# HostA 和 HostB
ip link set tap1 netns ns1  

配置

# HostA 
ip netns exec ns1 ip addr add 192.168.0.110/24 dev tap1  
ip netns exec ns1 ip link set tap1 up  
ip netns exec ns1 ip link set lo up  
ip netns exec ns1 ping 192.168.0.110

# HostB
ip netns exec ns1 ip addr add 192.168.0.111/24 dev tap1  
ip netns exec ns1 ip link set tap1 up  
ip netns exec ns1 ip link set lo up  
ip netns exec ns1 ping 192.168.0.111  

设置vxlan

# HostA
ovs-vsctl add-port br1 vxlan0 -- set Interface vxlan0 type=vxlan options:remote_ip=172.16.8.106

# HostB
ovs-vsctl add-port br1 vxlan0 -- set Interface vxlan0 type=vxlan options:remote_ip=172.16.8.105  

测试(在HostA执行)

ip netns exec ns1 ping 192.168.0.110  
ip netns exec ns1 ping 192.168.0.111  

Viewing all articles
Browse latest Browse all 290

Trending Articles