Manage routers and static routes
Create routers, set or clear their external gateway, attach and detach subnets, add static routes, and rename or delete routers in the console.
Create routers, attach subnets to them, give them a path to the internet, and send address ranges to a next hop with static routes. For how routers work, see Routers.
Before you begin
- You need the Owner or Contributor role on the subscription or on the project, or a custom role with Manage access to Networking. To view routers, any role with Read access to Networking is enough.
- For an external gateway, your project must be allowed to use an external network for Floating IPs and router gateways. The region's operator decides which external networks each project can use.
- Routers count against the subscription's quota and the project's allocation, and a router is billed by the hour when routers have a price in your region. See Quotas and Billing.
Create a router
In the console, go to NetworkingRouters, and select Create router.
In Name, enter a name: 1–63 lowercase letters, numbers, and hyphens, unique within the project.
Select Create router. The console returns to the list of routers.
The router is Building until the platform finishes it, and then Active. The platform gives the router an external gateway on one of the external networks that your project can use for Floating IPs and router gateways. You don't choose the network. If your project can use none, the router is created without a gateway.
A new router has no interfaces and no static routes. Attach a subnet next.
Set or clear the external gateway
In the console, go to NetworkingRouters, and open the router.
Select Set gateway or Clear gateway, at the top of the page or on the Interfaces tab.
In the dialog, select Set gateway or Clear gateway again.
While the platform changes the gateway, the router is Building. The console then shows External gateway set or External gateway cleared.
- Set. The platform picks the external network, the same way as when you create a router. If your project can use none, the request is refused, and the router stays without a gateway.
- Clear. The router's subnets lose their path to the internet, and the internet access check of their instances fails at its External gateway step.
Attach a subnet
On the router's page, select Add interface. The Interfaces tab opens with a new row.
In the Select a subnet… list, select the subnet. The list names each subnet with its network and its address block. Subnets that are already attached to this router aren't listed.
Select the check mark. When the interface is in place, the console shows Interface attached, and the interface appears in the list.
The router then forwards traffic between this subnet and its other subnets and, when it has an external gateway, to the internet.
Detach a subnet
On the router's page, select the Interfaces tab.
Point to the subnet's row, and select the trash icon. The console detaches the subnet right away, without asking for confirmation.
Instances on the subnet lose their path through this router.
You can't detach an interface marked Service port. Another service in the cloud attached it, and only that service can remove it.
Add a static route
The next hop must be reachable through a subnet that the router is connected to: an attached subnet or its external gateway's network. For a next hop in one of your subnets, attach that subnet first.
On the router's page, select Add route. The Static routes tab opens with a new row.
Enter the destination block and the next hop.
Select the check mark. The console shows Static route added when the route is in place.
| Field | Rule |
|---|---|
| Destination CIDR | A block that starts at its first address, for example 10.20.0.0/16. One route per destination on a router. |
| Next hop | An IP address that the router reaches through an attached subnet or its external gateway's network, for example 10.0.1.254. |
Remove a static route
On the router's page, select the Static routes tab.
Point to the route's row, and select the trash icon. There's no confirmation. When the route is gone, the console shows Static route removed.
Check the route table
To see how the static routes combine with the routes of the attached subnets and the external gateway, open the Route table tab. See Route table.
Rename a router or change its admin state
On the router's page, select Edit.
Change Name or Admin state.
Select Save changes. The console shows Router updated.
A router that the platform is still creating can't be changed yet.
Delete a router
On the router's page, select Delete.
Select Delete router.
The console clears the external gateway, detaches every interface, and then deletes the router. The subnets stay, without a path through this router.
You can also delete routers from the list. Select their check boxes, select Delete, and confirm. The console tears each router down the same way.
Troubleshooting
| Symptom | Cause | Resolution |
|---|---|---|
| A new router has no external gateway, and setting one is refused. | Your project can't use any external network for router gateways. | Ask the region's operator to let your project use an external network for Floating IPs and router gateways. See Contact. |
| Failed to add static route | The destination doesn't start at its first address, the router already has a route for it, or the next hop isn't reachable through an attached subnet or the external gateway's network. | Correct the route, or attach the subnet of the next hop first. |
| Failed to update router | The platform is still creating the router, or another router in the project has the name. | Wait until the router's creation finishes, or choose another name. |
| The trash icon of an interface is unavailable, with This is a service port — it cannot be detached from the portal. | The interface is a service port. | Only the service that attached it can remove it. |
| The trash icon of an interface is unavailable, with This interface has no id yet — reload the router once it finishes provisioning. | The interface is still being set up. | Reload the router's page when it's finished. |
| The router shows Error. | The cloud refused the create or the last change. | Read the reason under What the provider reported on the router's page. |