简体   繁体   English

Ping无法在OpenStack实例中获得第二个IP

[英]Ping failed to second ip in openstack instance

I have RDO openstack environment in a machine for testing. 我在一台机器上有RDO openstack环境进行测试。 The RDO was installed with packstack --allinone command. RDO是使用packstack --allinone命令安装的。 Using HOT I have created two instances. 使用HOT,我创建了两个实例。 One with cirros image and another with Fedora . 一个带有卷cirros图像,另一个带有Fedora The Fedora instance have two interfaces that are connected to same network while cirros have only one interface and connected to same network. Fedora实例具有两个连接到同一网络的接口,而cirros仅具有一个接口并连接到同一网络。 The template looks like this - 模板看起来像这样-

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 }

The Fedora instance got two ips (50.0.0.3 and 50.0.0.4). Fedora实例获得两个IP(50.0.0.3和50.0.0.4)。 Cirros got ip 50.0.0.5. Cirros的IP为50.0.0.5。 I can ping 50.0.0.3 from cirros instance but not the ip 50.0.0.4. 我可以从cirros实例ping 50.0.0.3,但不能从ip 50.0.0.4 ping通。 If I manually down the interface with ip 50.0.0.3 in the Fedora instance, then only I can ping 50.0.0.4 from cirros instance. 如果我在Fedora实例中使用ip 50.0.0.3手动关闭接口,那么只有我可以从cirros实例ping 50.0.0.4。 Is there a restriction in the configuration of neutron that prohibits ping to both the ips of Fedora instance at same time. 中子的配置是否有限制,禁止同时对Fedora实例的两个ip进行ping操作。 Please help. 请帮忙。

This happens because of the default firewall-ing done by OpenStack networking (neutron) -- it simply drops any packets received on a port if the source address of the packet does not match the IP address assigned to the port. 发生这种情况是由于OpenStack网络(neutron)进行了默认的防火墙保护-如果数据包的源地址与分配给该端口的IP地址不匹配,它只会丢弃端口上接收到的所有数据包。

When cirros instance sends ping packet to 50.0.0.4, fedora instance receives it on the interface with IP address 50.0.0.4. 当cirros实例将ping数据包发送到50.0.0.4时,fedora实例在IP地址为50.0.0.4的接口上接收到它。 However, when it is responding back to cirros's IP address 50.0.0.5, the linux networking stack on your fedora machine has two interfaces to choose from to send out the response (because both those interfaces are connected to the same network). 但是,当它响应cirros的IP地址50.0.0.5时,fedora机器上的linux网络堆栈有两个接口可供选择以发送响应(因为这两个接口都连接到同一网络)。 In your case, fedora choose to respond back on on 50.0.0.3. 在您的情况下,fedora选择在50.0.0.3上回复。 However, the source IP address in the packet is still 50.0.0.4, and thus the OpenStack networking layer simply drops it. 但是,数据包中的源IP地址仍然是50.0.0.4,因此OpenStack网络层只是将其丢弃。

General recommendation is to not have multiple interfaces on the same network. 一般建议不要在同一网络上有多个接口。 If you want multiple IP addresses from the same network for your VM, you can use "fixed_ips" option in your heat template: 如果要为您的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"

Since DHCP server would offer only IP address, fedora would be configured with only one IP. 由于DHCP服务器仅提供IP地址,因此fedora仅配置有一个IP。 You can add another IP to your interface using "ip addr add" command (see http://www.unixwerk.eu/linux/redhat/ipalias.html ): 您可以使用“ 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM