Static routes in cloud platform networks
Static routing can be used if there is a device on the cloud subnet that acts as a router. You can:
- configure static routes on the subnet subnet where devices, such as cloud servers, reside;
- configure static routes on the cloud router.
To configure static routes on a global router, use the instructions to Configure Routing on a Global Router.
Examples of tasks to be solved
Internet access for a network connected to a global router
For example, a cloud platform's private network is connected to a global router, and you need to:
- configure Internet access for cloud servers that are located in subnets of this private network;
- Configure Internet access for the Managed Kubernetes cluster private subnet to deploy nodes;
- Use a public IP address for a cloud server or for a load balancer on a private network;
- Use the cloud router as a gateway to access the internet for servers or hosts from other pools and services.
Sending traffic through a cloud server (proxy)
If you need to send traffic to other subnets, you can use the cloud server as a gateway and configure static routing. For example:
- configure access to the Internet from a subnet;
- configure connectivity to the external infrastructure via VPN.
Configure static routes in a subnetwork
You can use as the source subnet:
- a private subnet;
- subnet of the global router;
- public subnet — only through the OpenStack CLI;
- private networks and public subnets to which access is configured in different projects (with the CrossProject tag) — only via OpenStack CLI.
You cannot set a metric (route weight or cost) for a static route, so you cannot configure two or more routes with the same source subnet and destination subnet.
Control panel
OpenStack CLI
When configuring a static route in the control panel, you can select a private subnet or a global router subnet as the source subnet.
- In the dashboard, on the top menu, click Products and select Cloud Servers.
- Go to Network → Private Networks tab.
- Open the Private Network page → Subnets tab.
- In the subnet card, open the Automatic Network Settings block.
- Click Add Route.
- Enter the CIDR of the destination subnet, which is the subnet to which traffic will be routed.
- Enter the gateway (next-hop) — the IP address through which devices on the source subnet will route traffic to the destination subnet. You can enter any address from the source subnet.
- Click .
- Apply the changes. To do this, update the network settings on the devices in the subnet.
When configuring a static route through the OpenStack CLI, you can select the following as the source subnet: private subnet, global router subnet, public subnet, and private or public subnet that is configured to be accessed by different projects (tagged **Cross-Project **).
-
Configure a static route:
openstack subnet set \
--host-route destination=<destination_subnet_cidr>,gateway=<next_hop_ip_address> \
<subnet>Specify:
<destination_subnet_cidr>
— CIDR of the destination subnet to which traffic will be routed, e.g.172.16.0.8/29
;<next_hop_ip_address>
— gateway (next-hop) — The IP address through which devices on the source subnet will route traffic to the destination subnet. You can enter any address from the source subnet;<subnet>
— The ID or name of the source subnet can be viewed with the commandopenstack subnet list
.
If you have previously configured static routes, want to remove all routes and add a new route at the same time, use the
--no-host-route
parameter:openstack subnet set \
--no-host-route \
--host-route destination=<destination_subnet_cidr>,gateway=<next_hop_ip> \
<subnet> -
Check that a static route has been added. To do this, look for the
destination
andgateway
parameters in the command output:openstack subnet show <subnet>
-
Apply the changes. To do this, update the network settings on the devices in the subnet.
Configure static routes on the cloud router
OpenStack CLI
-
Configure a static route:
openstack router add route \
--route destination=<destination_subnet_cidr>,gateway=<next_hop_ip_address> \
<router>Specify:
<destination_subnet_cidr>
— CIDR of the destination subnet to which traffic will be routed, e.g.172.16.0.8/29
;<next_hop_ip_address>
— gateway (next-hop) — the IP address that is specified on the cloud router, e.g.172.16.0.1
. You can view it with the commandopenstack router show <router>
The value ofip_address
in theinterfaces_info
;<router>
— The ID or name of the cloud router can be viewed with the commandopenstack router list
.