Add a router to connect instances to external subnets
Add a router to enable instance communication with external subnets.
Before you begin Copy linkLink copied!
- The administrator has created a project for you and has provided you with a
clouds.yamlfile for you to access the cloud. - The
python-openstackclientpackage is on your workstation.$ dnf list installed python-openstackclient
About this task Copy linkLink copied!
Instances need routers to communicate with external subnets, including those in the physical network. Routers and subnets connect using interfaces, with each subnet requiring its own interface to the router.
The default gateway of a router defines the next hop for any traffic received by the router. Its network is typically configured to route traffic to the external physical network by using a virtual bridge.
Procedure Copy linkLink copied!
Results Copy linkLink copied!
- Confirm that the router was created:
$ openstack router list -c Name -c Status -c State -c Project- Sample output
+---------+--------+-------+----------------------------------+ | Name | Status | State | Project | +---------+--------+-------+----------------------------------+ | router1 | ACTIVE | UP | 24089d2fe1a94dd29ca2f665794fbe92 | | router2 | ACTIVE | UP | ecf285621c509223ade3358691bbde59 | +---------+--------+-------+----------------------------------+
What to do next Copy linkLink copied!
- Proceed to Adding a subnet to a router.
Add a subnet to a router Copy linkLink copied!
Add a subnet interface to a router to enable traffic routing.
Before you begin Copy linkLink copied!
- The administrator has created a project for you and has provided you with a
clouds.yamlfile for you to access the cloud. - The
python-openstackclientpackage is on your workstation.$ dnf list installed python-openstackclient - You have access to a virtual router.
Procedure Copy linkLink copied!
Results Copy linkLink copied!
- Confirm that the router lists the interface that was added:
- Example
$ openstack router show router2 --max-width=72- Sample output
+-------------------------+--------------------------------------------+ | Field | Value | +-------------------------+--------------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2024-09-09T06:27:48Z | | description | | | external_gateway_info | {"network_id": | | | "bcdb3cc0-8c0b-4d2d-813c-e141bb97aa8f", | | | "external_fixed_ips": [{"subnet_id": | | | "6745edd4-d15f-4971-89bf-70307b0ad2f1", | | | "ip_address": "10.0.0.167"}, {"subnet_id": | | | "cc3f81bb-4d55-4ead-aad4-5362a7ca5b04", | | | "ip_address": "2620:52:0:13b8::1000:85"}], | | | "enable_snat": true} | | flavor_id | None | | id | 9119eade-cf28-42d7-a33d-eb589469bf62 | | interfaces_info | [{"port_id": | | | "5a40b083-27d0-4691-8208-99c507181a33", | | | "ip_address": "10.0.24.1", "subnet_id": | | | "47d34cf0-0dd2-49bd-a985-67311d80c5c4"}, | | | {"port_id": | | | "642e522e-2cbd-47b5-8f8b-88c1b5d5e535", | | | "ip_address": "10.1.2.1", "subnet_id": | | | "7ee56cef-83c0-40d1-b4e7-5287dae1c23c"}, | | | {"port_id": | | | "9f695259-680c-40a8-bbed-9ca84dd77c33", | | | "ip_address": "10.0.1.1", "subnet_id": | | | "d7535565-113f-4192-baa6-da21f301f141"}, | | | {"port_id": | | | "f43a55a7-2e91-4cb7-a6b2-b3b686fc2ebd", | | | "ip_address": "10.0.2.1", "subnet_id": | | | "317be3d3-5265-43f7-b52b-930e3fd19b8b"}] | | name | router2 | | project_id | ecf285621c509223ade3358691bbde59 | | revision_number | 7 | | routes | | | status | ACTIVE | | tags | | | updated_at | 2024-09-09T09:28:40Z | +-------------------------+--------------------------------------------+
Remove a subnet from a router Copy linkLink copied!
Remove a subnet interface from a router to disconnect that Layer 3 segment from the router..
Before you begin Copy linkLink copied!
- The administrator has created a project for you and has provided you with a
clouds.yamlfile for you to access the cloud. - The
python-openstackclientpackage is on your workstation.$ dnf list installed python-openstackclient - You have access to a virtual router.
Procedure Copy linkLink copied!
Results Copy linkLink copied!
- Confirm that the subnet has been removed from the router:
- Example
-
$ openstack router show router2 --max-width=72 - Sample output
-
+-------------------------+--------------------------------------------+ | Field | Value | +-------------------------+--------------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2024-09-09T06:27:48Z | | description | | | external_gateway_info | {"network_id": | | | "bcdb3cc0-8c0b-4d2d-813c-e141bb97aa8f", | | | "external_fixed_ips": [{"subnet_id": | | | "6745edd4-d15f-4971-89bf-70307b0ad2f1", | | | "ip_address": "10.0.0.167"}, {"subnet_id": | | | "cc3f81bb-4d55-4ead-aad4-5362a7ca5b04", | | | "ip_address": "2620:52:0:13b8::1000:85"}], | | | "enable_snat": true} | | flavor_id | None | | id | 9119eade-cf28-42d7-a33d-eb589469bf62 | | interfaces_info | [{"port_id": | | | "5a40b083-27d0-4691-8208-99c507181a33", | | | "ip_address": "10.0.24.1", "subnet_id": | | | "47d34cf0-0dd2-49bd-a985-67311d80c5c4"}, | | | {"port_id": | | | "642e522e-2cbd-47b5-8f8b-88c1b5d5e535", | | | "ip_address": "10.1.2.1", "subnet_id": | | | "7ee56cef-83c0-40d1-b4e7-5287dae1c23c"}, | | | {"port_id": | | | "9f695259-680c-40a8-bbed-9ca84dd77c33", | | | "ip_address": "10.0.1.1", "subnet_id": | | | "d7535565-113f-4192-baa6-da21f301f141"}, | | name | router2 | | project_id | ecf285621c509223ade3358691bbde59 | | revision_number | 7 | | routes | | | status | ACTIVE | | tags | | | updated_at | 2024-09-09T11:14:33Z | +-------------------------+--------------------------------------------+
Remove an unused router Copy linkLink copied!
Delete a router that has no connected interfaces. This frees up a router and keeps the environment tidy.
Before you begin Copy linkLink copied!
- The administrator has created a project for you and has provided you with a
clouds.yamlfile for you to access the cloud. - The
python-openstackclientpackage is on your workstation.$ dnf list installed python-openstackclient - No interfaces are connected to the router that you want to delete.
Procedure Copy linkLink copied!
Results Copy linkLink copied!
- Confirm that the router was deleted:
$ openstack router list -c Name -c Status -c State -c Project- Sample output
-
+---------+--------+-------+----------------------------------+ | Name | Status | State | Project | +---------+--------+-------+----------------------------------+ | router1 | ACTIVE | UP | 24089d2fe1a94dd29ca2f665794fbe92 | +---------+--------+-------+----------------------------------+