具有多个隧道 ID 的 OvS VXLAN 隧道仅适用于一个隧道 ID

OvS VXLAN tunnel with multiple tunnel IDs works only for one tunnel ID

我想在不同 VM 上的 Linux 网络接口之间设置 VXLAN 隧道。更准确地说,拓扑结构如下。我有两个安装了 OvS 2.5.5 的 Ubuntu 16.04 Vag运行t 盒子。在每个虚拟机上,我创建了一个名为 kos 的 OvS 网桥,并使用以下命令为每个网桥添加了一个 vxlan port/interface:

ovs-vsctl add-port kos vtep -- set interface vtep type=vxlan option:remote_ip=flow option:key=flow

然后我在每台机器上创建了两个 Linux 网络接口。同一台机器上的接口具有相同的 IP 地址但不同 MAC 地址。我希望将四个接口拆分为两个独立的 VXLAN(分别为 ID 1 和 2),并使用 OvS VXLAN 隧道在同一 VXLAN 中的不同 VM 上实现接口之间的通信。用于创建接口并将它们连接到 OvS 的命令是:

VM1:

ovs-vsctl add-port kos kos11 -- set interface kos11 type=internal mac="02\:00\:00\:00\:00\:11" && ip addr add 10.0.0.1/8 scope link dev kos11 && ip link set kos11 up
ovs-vsctl add-port kos kos21 -- set interface kos21 type=internal mac="02\:00\:00\:00\:00\:21" && ip addr add 10.0.0.1/8 scope link dev kos21 && ip link set kos21 up

VM2:

ovs-vsctl add-port kos kos12 -- set interface kos12 type=internal mac="02\:00\:00\:00\:00\:12" && ip addr add 10.0.0.2/8 scope link dev kos12 && ip link set kos12 up
ovs-vsctl add-port kos kos22 -- set interface kos22 type=internal mac="02\:00\:00\:00\:00\:22" && ip addr add 10.0.0.2/8 scope link dev kos22 && ip link set kos22 up

每个接口名称由"kos"后跟两位数字组成,第一个是接口的VNI,第二个是它所属的VM的编号。

最后,我检索了每个接口的 openflow 端口(两个 VM 上的 vtep,kos11、kos21、kos12、kos22),并添加了以下 OpenFlow 流:

VM1:

table=0,in_port=2,actions=set_field:1->tun_id,resubmit(,1)
table=0,in_port=3,actions=set_field:2->tun_id,resubmit(,1)
table=0,actions=resubmit(,1)

table=1,tun_id=1,arp,arp_tpa=10.0.0.1,actions=output:2
table=1,tun_id=1,dl_dst=02:00:00:00:00:11,actions=output:2

table=1,tun_id=2,arp,arp_tpa=10.0.0.1,actions=output:3
table=1,tun_id=2,dl_dst=02:00:00:00:00:21,actions=output:3

table=1,tun_id=1,arp,arp_tpa=10.0.0.2,actions=set_field:172.28.128.5->tun_dst,output:1
table=1,tun_id=1,dl_dst=02:00:00:00:00:12,actions=set_field:172.28.128.5->tun_dst,output:1

table=1,tun_id=2,arp,arp_tpa=10.0.0.2,actions=set_field:172.28.128.5->tun_dst,output:1
table=1,tun_id=2,dl_dst=02:00:00:00:00:22,actions=set_field:172.28.128.5->tun_dst,output:1

table=1,actions=drop

VM2:

table=0,in_port=2,actions=set_field:1->tun_id,resubmit(,1)
table=0,in_port=3,actions=set_field:2->tun_id,resubmit(,1)
table=0,actions=resubmit(,1)

table=1,tun_id=1,arp,arp_tpa=10.0.0.2,actions=output:2
table=1,tun_id=1,dl_dst=02:00:00:00:00:12,actions=output:2

table=1,tun_id=2,arp,arp_tpa=10.0.0.2,actions=output:3
table=1,tun_id=2,dl_dst=02:00:00:00:00:22,actions=output:3

table=1,tun_id=1,arp,arp_tpa=10.0.0.1,actions=set_field:172.28.128.4->tun_dst,output:1
table=1,tun_id=1,dl_dst=02:00:00:00:00:11,actions=set_field:172.28.128.4->tun_dst,output:1

table=1,tun_id=2,arp,arp_tpa=10.0.0.1,actions=set_field:172.28.128.4->tun_dst,output:1
table=1,tun_id=2,dl_dst=02:00:00:00:00:21,actions=set_field:172.28.128.4->tun_dst,output:1

table=1,actions=drop

1 是与两个 VM 上的接口 vtep 关联的开放流端口。

在 VM1 上,2 和 3 分别是与接口 kos11 和 kos21 关联的开放流端口。

在 VM2 上,2 和 3 分别是与接口 kos12 和 kos22 关联的开放流端口。

1是kos11和kos12所属的VXLAN的VNI,2是kos21和kos22所属的VXLAN的VNI。

172.28.128.4 和 172.28.128.5 是两个 VM 可以相互 ping 的网络接口的 IP 地址(也就是隧道端点的 IP)。

执行上述步骤后,kos11 可以 ping kos12,反之亦然(也就是使用 VNI 1 的 VXLAN 隧道),而从 kos21 ping kos22,反之亦然会导致目标主机无法访问。我在 kos22 上 运行 tcpdump,同时从 kos21 ping 它,这就是我得到的:

ARP, Request who-has 10.0.0.2 tell 10.0.0.1, length 28
ARP, Request who-has 10.0.0.2 tell 10.0.0.1, length 28
ARP, Request who-has 10.0.0.2 tell 10.0.0.1, length 28

我做错了什么?我该如何解决这个问题?

它不起作用的原因是同一子网中不能有多个接口。我发现的解决方法是将每个接口放在一个单独的 Linux 网络命名空间中。