通过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

相关内容