透過ovs橋連接4個命名空間

透過ovs橋連接4個命名空間

我想問如何將4個命名空間連接到一個ovs橋,它們都在一台主機上。我為這 4 個命名空間嘗試了 2 對 veth,並將內部連接埠新增至網橋,但只能從 veth 的另一端 ping 通命名空間。

[root@centos7 ~]# ovs-vsctl show
689941bc-760e-451e-a91c-ddc33caf2396
Bridge brtest
    Port "test1"
        tag: 9
        Interface "test1"
            type: internal
    Port "test4"
        tag: 9
        Interface "test4"
            type: internal
    Port "test2"
        tag: 9
        Interface "test2"
            type: internal
    Port brtest
        Interface brtest
            type: internal
    Port "test3"
        tag: 9
        Interface "test3"
            type: internal
ovs_version: "2.7.0"

ip netns exec nstest1 ifconfig test1 promisc
ip netns exec nstest2 ifconfig test2 promisc
ip netns exec nstest3 ifconfig test3 promisc
ip netns exec nstest4 ifconfig test4 promisc

我開啟了namespace的veth的promisc,並分別指派ip從172.24.0.11到172.24.0.14。但只有 nstest1 可以連通 nstest2 , nstest3 可以連通 nstest4 ,因為 nstest1 和 nstest2 由一對 veth 連接,而 nstest3 和 nstest4 由另一對 veth 連接。

我可以讓它們完全通過這 4 個命名空間嗎?

答案1

我得到了答案,只需為這 4 個命名空間建立 veth 對,並將一端分配給命名空間,另一端作為連接埠新增至虛擬橋。那麼這4個命名空間可以從其中任一個通過

ip link set test1a netns nstest1
ip link set test2a netns nstest2
ip link set test3a netns nstest3
ip link set test4a netns nstest4
ovs-vsctl br-list
ovs-vsctl list-br
ovs-vsctl show
ovs-vsctl add-br br0
ovs-vsctl add-port br0 test1b
ovs-vsctl add-port br0 test2b
ovs-vsctl add-port br0 test3b
ovs-vsctl add-port br0 test4b
ip netns exec nstest1 ifconfig test1a 172.24.0.11/24 promisc up
ip netns exec nstest2 ifconfig test2a 172.24.0.12/24 promisc up
ip netns exec nstest3 ifconfig test3a 172.24.0.13/24 promisc up
ip netns exec nstest4 ifconfig test4a 172.24.0.14/24 promisc up

ip link set dev test2b up
ip link set dev test1b up
ip link set dev test3b up
ip link set dev test4b up

相關內容