OpenStack如何路由同一网络的2个子网

时间:2015-12-22 17:10:09

标签: networking routing openstack-neutron

我对Openstack比较新,我找不到如何路由同一网络的2个子网。

我的拓扑结构如下: 1. 1网络, 2.网络中的2个子网。 sub1(192.168.10.0/24)和sub2(192.168.20.0/24)

第一个sub1中的实例无法在sub2中看到另一个实例。

Q1:这是正常的吗?为什么默认情况下不会路由子网?

我尝试添加路由器,但路由器只能在内部网络和公共网络之间,但不能在子网之间。

Q2:那么在同一网络的2个子网中的2个实例之间进行通信的最佳解决方案是什么?

非常感谢。

2 个答案:

答案 0 :(得分:2)

对于一个与不同网络通信的网络,您需要一台路由器。我不知道你在哪里知道路由器只在公共和私人网络之间路由;对于路由器,它们只是两个不同的网络。

您有两个网络:192.168.10.0/24192.168.20.0/24。对于任一网络与其他网络通信,它们之间至少需要一个路由器,单个路由器是最简单的,因为它不涉及路由协议或静态定义的路由。

答案 1 :(得分:0)

好的,经过一些尝试,我终于找到了解决方案,我想与你分享。

首先,正如Ron所说,路由器不一定是通往公共网络的网关。

对于精度,我希望只有一个网络具有子网而不是2个网络。

解决方案是在每个子网 AND 上安装一个带有接口的路由器,以使用'host_routes'功能在每个子网上添加路由信息。

执行此操作的Heat堆如下:

  subnet_public:
    type: OS::Neutron::Subnet
    properties:
      name: PublicSubnet
      cidr: 192.168.11.0/24
      network: { get_resource: network_public }
      allocation_pools: [ { "start" : '192.168.11.1', "end" : '192.168.11.253'}]
      dns_nameservers: [ 'xx.xx.xx.xx', ...]
      enable_dhcp: True
      gateway_ip: 192.168.11.254
      host_routes: [ { 'destination' : '192.168.12.0/24', 'nexthop' : '192.168.11.254'}, { 'destination' : '192.168.13.0/24', 'nexthop' : '192.168.11.254'}]
      ip_version: 4
      # tenant_id: { get_param: tenantId }
  subnet_appli:
    type: OS::Neutron::Subnet
    properties:
      name: ApplicationSubnet
      cidr: 192.168.12.0/24
      network: { get_resource: network_public }
      allocation_pools: [ { "start" : '192.168.12.1', "end" : '192.168.12.253'}]
      dns_nameservers: [ 'xx.xx.xx.xx', ...]
      enable_dhcp: True
      gateway_ip: 192.168.12.254
      host_routes: [ { 'destination' : '192.168.11.0/24', 'nexthop' : '192.168.12.254'}, { 'destination' : '192.168.13.0/24', 'nexthop' : '192.168.12.254'}]
      ip_version: 4
      # tenant_id: { get_param: tenantId }
  subnet_database:
    type: OS::Neutron::Subnet
    properties:
      name: DatabaseSubnet
      cidr: 192.168.13.0/24
      network: { get_resource: network_public }
      allocation_pools: [ { "start" : '192.168.13.1', "end" : '192.168.13.253'}]
      dns_nameservers: [ 'xx.xx.xx.xx', ...]
      enable_dhcp: True
      gateway_ip: 192.168.13.254
      host_routes: [ { 'destination' : '192.168.11.0/24', 'nexthop' : '192.168.13.254'}, { 'destination' : '192.168.12.0/24', 'nexthop' : '192.168.13.254'}]
      ip_version: 4
      # tenant_id: { get_param: tenantId }
  #
  # Router
  router_nat:
    type: OS::Neutron::Router
    properties:
      name: routerNat
      admin_state_up: True
      external_gateway_info: { "network": 'ext-net' }
  gateway_itf:
    type: OS::Neutron::RouterInterface
    depends_on: [ network_public, subnet_public, router_nat ]
    properties:
      router_id: { get_resource: router_nat }
      subnet: { get_resource: subnet_public }
  router_appli_itf:
    type: OS::Neutron::RouterInterface
    depends_on: [ network_public, subnet_appli, router_nat ]
    properties:
      router_id: { get_resource: router_nat }
      subnet: { get_resource: subnet_appli }
  router_database_itf:
    type: OS::Neutron::RouterInterface
    depends_on: [ network_public, subnet_database, router_nat ]
    properties:
      router_id: { get_resource: router_nat }
      subnet: { get_resource: subnet_database }
相关问题