OpenStack 如何路由同一网络的 2 个子网
OpenStack how to route 2 subnet of the same Network
我对 Openstack 比较陌生,我找不到如何路由同一网络的 2 个子网。
我的拓扑如下:
1.1网络,
2. 网络中的 2 个子网。 sub1 (192.168.10.0/24) 和 sub2 (192.168.20.0/24)
第一个 sub1 中的实例无法看到 sub2 中的另一个实例。
Q1:这正常吗?为什么默认情况下不路由子网?
我尝试添加路由器,但路由器只能在内部网络和 Public 网络之间使用,但不能在子网之间使用。
问题 2:那么在同一网络的 2 个子网中的 2 个实例之间进行通信的最佳解决方案是什么?
非常感谢。
要让一个网络与另一个网络通信,您需要一个路由器。我不知道您从哪里得到路由器只在 public 和专用网络之间路由的想法;对于路由器来说,它们只是两个不同的网络。
您有两个网络:192.168.10.0/24
和 192.168.20.0/24
。对于任何一个网络与另一个网络进行通信,您至少需要一个路由器在它们之间,一个路由器是最简单的,因为它不会涉及路由协议或静态定义的路由。
好的,经过一番尝试,终于找到了解决方法,分享给大家。
首先,正如 Ron 上面所说,路由器不是 public 网络的网关。
为了精确起见,我只想拥有一个带子网的网络,而不是 2 个网络。
解决方案是在每个子网上设置一个带有接口的路由器并且使用'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 }
我对 Openstack 比较陌生,我找不到如何路由同一网络的 2 个子网。
我的拓扑如下: 1.1网络, 2. 网络中的 2 个子网。 sub1 (192.168.10.0/24) 和 sub2 (192.168.20.0/24)
第一个 sub1 中的实例无法看到 sub2 中的另一个实例。
Q1:这正常吗?为什么默认情况下不路由子网?
我尝试添加路由器,但路由器只能在内部网络和 Public 网络之间使用,但不能在子网之间使用。
问题 2:那么在同一网络的 2 个子网中的 2 个实例之间进行通信的最佳解决方案是什么?
非常感谢。
要让一个网络与另一个网络通信,您需要一个路由器。我不知道您从哪里得到路由器只在 public 和专用网络之间路由的想法;对于路由器来说,它们只是两个不同的网络。
您有两个网络:192.168.10.0/24
和 192.168.20.0/24
。对于任何一个网络与另一个网络进行通信,您至少需要一个路由器在它们之间,一个路由器是最简单的,因为它不会涉及路由协议或静态定义的路由。
好的,经过一番尝试,终于找到了解决方法,分享给大家。
首先,正如 Ron 上面所说,路由器不是 public 网络的网关。
为了精确起见,我只想拥有一个带子网的网络,而不是 2 个网络。
解决方案是在每个子网上设置一个带有接口的路由器并且使用'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 }