Static routes
Static routing can be used if there is a device on the cloud subnet that acts as a router. You can:
- configure static routes in a 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 following instructions 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 tag
Кросспроектная
) — only through the 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 control panels go to Cloud platform → Network.
- Open the tab Private networks.
- Open the private network page → tab Static routes.
- Click Add a route.
- Select the source subnet.
- 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 Add.
- Apply the changes. To do this update the network settings on devices in the subnetwork.
When configuring a static route through the OpenStack CLI, you can select as the source subnet: a private subnet, a global router subnet, a public subnet, and a private or public subnet that is configured to be accessed by different projects (with tagged Кросспроектная
).
-
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 the 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>
— ID or name of the source subnet, can be viewed with the commandopenstack subnet list
If you have previously configured static routes and want to delete all routes and add a new route at the same time, use the parameter
--no-host-route
:openstack subnet set \
--no-host-route \
--host-route destination=<destination_subnet_cidr>,gateway=<next_hop_ip> \
<subnet> -
Check that the static route has been added. To do this, look in the command output for the parameters
destination
(destination subnet) andgateway
(next-hop):openstack subnet show <subnet>
-
Apply the changes. To do this update the network settings on devices in the subnetwork.
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 the 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
. Can be viewed with the commandopenstack router show <router>
valueip_address
in the fieldinterfaces_info
;<router>
— The ID or name of the cloud router, can be viewed using the commandopenstack router list