Configure static routes on dedicated servers
Static routing is a type of routing where routes are explicitly defined when configuring a network interface on a server or router.
To configure static routing, add static routes on the server.
Examples of tasks that can be solved using static routing:
- connect dedicated servers and a cloud server over a private network ;
- route internet traffic through a firewall;
- configure connectivity with external infrastructure through a firewall.
Specify static routes on a server
Ubuntu
Debian
CentOS
Windows
-
View the configuration file name of the
netplanutility:ls /etc/netplan/The response will show the configuration file name. For example:
01-netcfg.yamlCopy the configuration file name.
-
Open the configuration file of the
netplanutility with the text editorvi:vi /etc/netplan/<file_name>Specify
<file_name>— the configuration file name that you copied in step 2. -
At the end of the block with parameters of the required network interface, add a route:
routes:- to: <ip_address>/<mask>via: <gateway>Specify:
<ip_address>— subnet to which the route is needed;<mask>— subnet mask for the subnet to which the route is needed;<gateway>— gateway for the current server subnet, for example, the gateway specified on the global router. The gateway address must be in the same subnet as the server.
-
If you need to configure multiple routes, add them sequentially in the same block, for example:
routes:- to: 192.168.0.0/28via: 192.168.0.1- to: 192.168.1.0/28via: 192.168.0.1 -
Press ESC.
-
Exit the text editor
visaving changes::wq -
Check the route configuration:
sudo netplan try -
Apply the changes:
netplan apply
Example of configuring static routes for connecting dedicated servers and a cloud server over a private network
Goal
Connect two dedicated servers in the SPB-2 pool and a cloud server in the ru-2 pool with a private network using a global router, and configure routing in the network so that the devices can communicate with each other.
Prerequisites
In the configuration example, we used two dedicated servers in the SPB-2 pool with access to a private network and a cloud server in the ru-2 pool.
Result
Private connectivity will be configured between two dedicated servers in the SPB-2 pool and a cloud server in the ru-2 pool.

Configuration steps
-
Connect private subnets to the global router:
192.168.0.0/28to the VLAN where the dedicated servers in the SPB-2 pool are located;172.16.0.0/28for the Cloud Platform project in the ru-2 pool.
-
Assign IP addresses from the private subnets you connected to the global router to the dedicated servers and cloud server. For more information, see the Assign IP addresses to servers section.
-
Configure routes:
- on each dedicated server in the SPB-2 pool — to the subnet
172.16.0.0/28via the gateway192.168.0.1; - on the cloud server in the ru-2 pool — to the subnet
192.168.0.0/28via the gateway172.16.0.1.
- on each dedicated server in the SPB-2 pool — to the subnet
Example of configuring static routes to direct Internet traffic through a firewall
Goal
Direct Internet traffic to a dedicated server through a firewall.
Prerequisites
In the configuration example, we used a dedicated server with access to a private network and a firewall.
Result
After configuring routed networks, Internet traffic to the dedicated server will pass through the firewall.

Configuration steps
-
Configure a static route on the dedicated server to the subnet
0.0.0.0/0via the gateway198.51.100.1. -
Configure default gateway
203.0.113.2on the firewall. -
To provide internet access on the dedicated server behind the firewall, create a ticket requesting to add a static route to the Selectel router. In the ticket, specify:
- private subnet of the dedicated server located behind the firewall, in the example —
198.51.100.0/28; - public IP address of the firewall, in the example —
203.0.113.2.
- private subnet of the dedicated server located behind the firewall, in the example —
-
Wait for a response from Selectel confirming that the static route has been configured on the router.
Example of configuring static routes for connecting to external infrastructure through a firewall
Goal
Connect two dedicated servers in the MSK-1 and SPB-2 pools to external infrastructure via a private network. Using a global router, configure routing in the network so that devices can communicate with each other, and direct routed network traffic through the firewall in the SPB-3 pool.
Prerequisites
In the configuration example, we used two dedicated servers in the MSK-1 and SPB-2 pools with access to a private network, a firewall in the SPB-3 pool, and external infrastructure.
Result
Private connectivity will be configured between external infrastructure and the servers in the MSK-1 and SPB-2 pools, and routed network traffic will pass through the firewall in the SPB-3 pool.

Configuration steps
-
Connect subnets to the global router:
192.168.11.0/24to the VLAN where the dedicated server in the MSK-1 pool is located;192.168.22.0/24to the VLAN where the dedicated server in the SPB-2 pool is located;192.168.33.0/24to the VLAN where the firewall in the SPB-3 pool is located.
-
Assign IP addresses from the private subnets you connected to the global router to the dedicated servers. For more information, see the Assign IP addresses to servers section.
-
Assign an IP address from the private subnet you connected to the global router to the firewall.
-
Configure routes on the servers:
- in the MSK-1 pool — to the subnets
192.168.22.0/24and192.168.33.0/24via the gateway192.168.11.1; - in the SPB-2 pool — to the subnets
192.168.11.0/24and192.168.33.0/24via the gateway192.168.22.1;
- in the MSK-1 pool — to the subnets
-
Configure routes on the firewall — to the subnets
192.168.11.0/24and192.168.22.0/24via the gateway192.168.33.1. -
Configure routing on the global router — specify a static route for outbound traffic to the Internet. Specify:
- destination subnet —
0.0.0.0/0; - Next hop — firewall IP address, in the example
192.168.33.2.
- destination subnet —