Routers in OpenStack can connect to a single external provider network and one or more tenant networks, as shown in the following diagram:
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:
openstack router set --external-gateway <network> <router>
openstack router add subnet <router> <subnet>
openstack router add port <router> <port>
When attaching a router to a network, the following information will be necessary:
Remember, when attaching a router to an external provider network, the network's router:external
attribute must be set to External
or True
.
To attach a network to a router in OpenStack, follow these steps:
COOKBOOK_PROVIDER_NET
:openstack router set --external-gateway COOKBOOK_PROVIDER_NET COOKBOOK_ROUTER_STANDALONE
No output is provided.
COOKBOOK_TENANT_SUBNET
subnet using the subnet name:openstack router add subnet COOKBOOK_ROUTER_STANDALONE COOKBOOK_TENANT_SUBNET_1
No output is provided.
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:
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
:
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.
13.58.114.29