Linux-Networking

主機無法使用 Open Vswitch 在兩個名稱空間中 ping

  • November 24, 2014

我有兩個名稱空間紅色和藍色。紅色連接host1,藍色連接host2,但是這兩台主機不能互相ping通。這是我輸入的命令:

ip link add host1 type veth peer name virt1
ip link add host2 type veth peer name virt2

ip netns add red
ip link set virt1 netns red

ip netns add blue
ip link set virt2 netns blue

ip netns exec red ip addr add 10.1.2.3/24 dev virt1
ip netns exec red ip link set virt1 up

ip netns exec blue ip addr add 10.1.2.5/24 dev virt2
ip netns exec blue ip link set virt2 up

ovs-vsctl add-br vsbr0 
ovs-vsctl add-port vsbr0 host1
ovs-vsctl add-port vsbr0 host2    

ovs-ofctl del-flows vsbr0
ovs-ofctl dump-flows vsbr0
ovs-ofctl add-flow vsbr0 action=normal

ip netns exec blue ping 10.1.2.3
ip netns exec red ping 10.1.2.5

應該打開主機並橋接:

ip link set host1 up
ip link set host2 up
ip link set dev vsbr0 up

引用自:https://serverfault.com/questions/646605