跨机器访问网络命名空间中的 Tap 接口

跨机器访问网络命名空间中的 Tap 接口

我希望能够从运行该服务的计算机外部访问命名空间内 TAP 接口上运行的服务。我的设置如下 -

VM1/Machine1
 +eth0 : Public Network
 +eth1 : Private Network (IP: 192.168.2.5/24)

VM2/Machine2
+========================================+
|                                        |
| eth0: Public Network 10.1.1.20/24 UP   |
| eth1: Private Network             UP   |
|----------------------------------------+
| Network Namespace : test               |
|  TAP0: 192.168.2.10/24, UP             |
|----------------------------------------|
|                                        |
+========================================+

我希望能够从 VM1/Machine1 ping/访问在命名空间测试下的 TAP0 上运行的服务。我使用了帖子“命名空间之间的 OpenVSwitch”和网上其他几篇文章中的信息来创建网桥,将“eth1”和“TAP0”放在同一个网桥上。但我仍然无法访问它。不确定还缺少什么?以下是我在 VM2/Machine2 上尝试的命令 -

ip netns add test
ovs-vsctl add-br br0
ovs-vsctl add-port br0 tap0 -- set interface tap0 type=internal
ip link set tap0 netns test
ip netns exec test ip addr add 192.168.2.10/24 dev tap0
ip netns exec test ip link set tap0 up
ovs-vsctl add-port br0 eth1 -- set interface eth1 type=internal

此后,桥接器“br0”具有“eth1”和“tap0”。因此,当我从 VM1 ping tap 接口的 IP 时,我认为我应该能够到达 tap0。这在没有命名空间的情况下可以正常工作,但有命名空间时则不起作用。

在另一次尝试中,我也尝试过

- creating 2 bridges
- one OVS bridge outside
- one linux bridge inside namespace
- created a veth pair
- ovs bridge has eth1 and one end of veth pair
- linux bridge in the namespace has 'tap' interface and other end of veth pair

但这也不起作用:(

我认为桥接的全部意义在于,如果我在其中添加接口/端口,我必须能够访问端口上的服务,就像交换机一样。我不确定我遗漏了什么。

相关内容