1

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

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

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

Q1:这正常吗?为什么子网默认不路由?

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

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

提前谢谢了。

4

2 回答 2

2

要使一个网络与另一个网络通信,您需要一台路由器。我不知道您从哪里得到路由器仅在公共网络和专用网络之间路由的想法;对路由器来说,它们只是两个不同的网络。

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

于 2015-12-23T08:45:25.263 回答
0

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

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

为了精确起见,我只想拥有一个带有子网的网络,而不是 2 个网络。

解决方案是在每个子网上都有一个带有接口的路由器,并使用“host_routes”功能在每个子网上添加路由信息。

执行此操作的热堆栈如下:

  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 }
于 2016-01-04T16:38:07.273 回答