Attaching networks to routers

Routers in OpenStack can connect to a single external provider network and one or more tenant networks, as shown in the following diagram:

Attaching networks to routers

Figure 4.3

In Figure 4.3, an external provider network provides external connectivity, while tenant networks provide connectivity to virtual machines and other virtual network devices within a project. The router's job is to facilitate end-to-end connectivity using routes and sometimes the NAT via floating IPs.

The commands necessary to attach a network to a router may vary based on network and need:

  • Attaching a router to an external network:
    openstack router set --external-gateway <network> <router>
    
  • Attaching a router to a tenant network using subnet ID or name:
    openstack router add subnet <router> <subnet>
    
  • Attaching a router to a tenant network using a specific port ID or name:
    openstack router add port <router> <port>
    

Getting ready

When attaching a router to a network, the following information will be necessary:

  • Router name or ID
  • Network name or ID, or Subnet name or ID, or Port name or ID

Remember, when attaching a router to an external provider network, the network's router:external attribute must be set to External or True.

How to do it…

To attach a network to a router in OpenStack, follow these steps:

  1. Attach the router to the external provider network COOKBOOK_PROVIDER_NET:
    openstack router set --external-gateway COOKBOOK_PROVIDER_NET COOKBOOK_ROUTER_STANDALONE
    

    No output is provided.

  2. Attach the router to the COOKBOOK_TENANT_SUBNET subnet using the subnet name:
    openstack router add subnet COOKBOOK_ROUTER_STANDALONE COOKBOOK_TENANT_SUBNET_1
    

    No output is provided.

How it works...

When routers are attached to external provider networks, the router is assigned an IP address from the pool of addresses available for allocation from the network. The router is also configured with a default gateway that corresponds to the specified gateway for the respective provider subnet.

When a router is attached to a tenant network, the router becomes the gateway for the attached network and all instances within it. It is assigned the IP address specified as the gateway for the respective tenant subnet.

Ports attached to routers can be listed using the following command:

openstack port list --router ROUTER_NAME_OR_ID

In this example, the following ports and corresponding subnets have been attached to the router:

How it works...

Using the ip netns exec command, coupled with the name of the respective router namespace, we can see the router has two attached interfaces, qg-ed006ed1-b8 and qr-c69005cb-aa:

How it works...

Note

The names of the interfaces in the router namespace correspond to the first 10 characters of the respective port ID. External, or gateway-side, interfaces are prefixed with qg-, while internal, or router-side, interfaces are prefixed with qr-. The naming scheme dates back to when the Neutron project was known as Quantum.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.114.29