Openstack Neutron - VM作为同一租户中两个网络之间的路由器



我有以下设置:

VM1---NET1---VM2---NET2---VM3

VM2 可以 ping VM1 和 VM3。但是,当从 VM1 到 VM3 执行 ping 操作时,数据包由 VM2 转发,但永远不会到达 VM3(即,由于 tcpdump 显示数据包是从 VM2 的 NET2 接口发送出去的,因此 NET2 会丢弃数据包)。

从 VM3 执行 ping 操作到 VM1 时也是如此。数据包到达 VM2,然后 VM2 将它们转发到 V1,但它们永远不会到达 VM1。

看起来 NET2 不允许具有 NET1 的 srcIP 的数据包通过。与 NET2 的 srcIP 过滤数据包相同。

这就是我们在热模板中创建每个网络的方式。

net1:
type: OS::Neutron::Net
properties:
name: net1_name
net1_subnet:
type: OS::Neutron::Subnet
properties:
network_id: { get_resource: net1 }
cidr: { get_param: net1_cidr }

有没有办法使数据包通过充当路由器的 VM2 从 NET1 流向 NET2?

谢谢!

========== 更新 ====

看起来我找到了一个解决方案:将VM1和VM3的IP添加到VM2的端口(Neutron:Port)的"allowed_address_pairs"。

VM2_left_port:
type: OS::Neutron::Port
properties:
allowed_address_pairs: [{"ip_address": { get_param: VM3_IP}}]
network: ...
fixed_ips: ...
VM2_right_port:
type: OS::Neutron::Port
properties:
allowed_address_pairs: [{"ip_address": { get_param: VM1_IP }}]
network: ...
fixed_ips: ...

这是否是允许在网络之间路由(使用 VM2 作为路由器)的正确方法的问题。

所以问题实际上是Openstack的"port_security"功能,它阻止从一个子网到另一个子网的流量。为了允许数据包在子网之间流动,可以使用以下选项作为我在问题("allowed_address_pairs")中提出的方法的替代方法。

VM2_left_port:
type: OS::Neutron::Port
properties:
security_groups: []
port_security_enabled: False
network: ...
fixed_ips: ...
VM2_right_port:
type: OS::Neutron::Port
properties:
security_groups: []
port_security_enabled: False
network: ...
fixed_ips: ...

我认为允许VM2中的两个网络接口之间进行互通。

echo 1>/proc/sys/net/ipv4/ip_forward

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

sudo iptables -A FORWARD -i eth0 -o eth1 -m state --state 相关,已建立 -J 接受

sudo iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

最新更新