Ping无法在openstack实例中进行第二次ip

时间:2016-04-14 05:51:38

标签: openstack openstack-neutron rdo

我在一台机器上有RDO openstack环境进行测试。 RDO安装了packstack --allinone命令。使用HOT我创建了两个实例。一个是cirros图片,另一个是FedoraFedora实例有两个连接到同一网络的接口,而cirros只有一个接口并连接到同一网络。模板看起来像这样 -

heat_template_version: 2015-10-15
description: Simple template to deploy two compute instances

resources:

   local_net:
     type: OS::Neutron::Net

   local_signalling_subnet:
     type: OS::Neutron::Subnet
     properties:
       network_id: { get_resource: local_net }
       cidr: "50.0.0.0/24"
       ip_version: 4

   fed:
     type: OS::Nova::Server
     properties:
     image: fedora
     flavor: m1.small
     key_name: heat_key
     networks:
        - network: local_net
     networks:
        - port: { get_resource: fed_port1 }
        - port: { get_resource: fed_port2 }

   fed_port1:
     type: OS::Neutron::Port
     properties:
      network_id: { get_resource: local_net }

  fed_port2:
    type: OS::Neutron::Port
    properties:
      network_id: { get_resource: local_net }

  cirr:
    type: OS::Nova::Server
    properties:
       image: cirros
       flavor: m1.tiny
       key_name: heat_key
    networks:
       - network: local_net
    networks:
       - port: { get_resource: cirr_port }

 cirr_port:
    type: OS::Neutron::Port
    properties:
      network_id: { get_resource: local_net }

Fedora实例获得了两个ips(50.0.0.3和50.0.0.4)。 Cirros获得了ip 50.0.0.5。我可以从cirros实例ping 50.0.0.3而不是ip 50.0.0.4。如果我在Fedora实例中使用ip 50.0.0.3手动关闭接口,那么我只能从cirros实例ping 50.0.0.4。中子的配置是否存在限制,禁止同时ping Fedora实例的ips。请帮忙。

1 个答案:

答案 0 :(得分:0)

这是因为OpenStack网络(neutron)完成了默认防火墙 - 如果数据包的源地址与分配给端口的IP地址不匹配,它只会丢弃端口上收到的所有数据包。

当cirros实例发送ping数据包到50.0.0.4时,fedora实例在IP地址为50.0.0.4的接口上接收它。但是,当它响应cirros的IP地址50.0.0.5时,Fedora机器上的linux网络堆栈有两个可供选择的接口来发送响应(因为这两个接口都连接到同一网络)。在你的情况下,fedora选择回复50.0.0.3。但是,数据包中的源IP地址仍为50.0.0.4,因此OpenStack网络层只会丢弃它。

一般建议在同一网络上没有多个接口。如果您想为VM的同一网络提供多个IP地址,可以在热模板中使用“fixed_ips”选项:

fed_port1:
  type: OS::Neutron::Port
  properties:
    network_id: { get_resource: local_net }
    fixed_ips:
    - ip_address: "50.0.0.4"
    - ip_address: "50.0.0.3"

由于DHCP服务器仅提供IP地址,因此Fedora将仅配置一个IP。您可以使用“ip addr add”命令向界面添加另一个IP(请参阅http://www.unixwerk.eu/linux/redhat/ipalias.html):

ip addr add 50.0.0.3/24 brd + dev eth0 label eth0:0