Search code examples
network-programmingroutesopenstack-neutron

OpenStack how to route 2 subnet of the same Network


I'm relatively new to Openstack and I cannot find how to route 2 subnets of the same Network.

My topologie is the following : 1. 1 Network, 2. 2 subnets in Network. sub1 (192.168.10.0/24) and sub2 (192.168.20.0/24)

An instance in first sub1 cannot see another instance in sub2.

Q1 : is this normal ? Why are subnet not routed by default ?

I try to add router but router is only possible between an internal Network and a Public Network, but not between subnets.

Q2 : So what is the best solution to communicate between 2 instances in 2 subnets of the same Network ?

Many thank's in advance.


Solution

  • OK, after some tries, I finally find a solution and I want to share it with you.

    First, as said by Ron above a router is not necessary a gateway to public networks.

    For a precision, I want to have only one network with subnets and not 2 networks.

    The solution is to have a router with an interface on each subnet AND to add routing information on each subnet using 'host_routes' features.

    A Heat stack doing this is the following:

      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 }