---
title: "Static Routes in Cloud Platform Networks"
sidebar_label: "Static Routes"
description: "How to configure static routes for subnets and on a cloud router⁠"
sidebar_position: 4
---

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'
import CheckIcon from '@selectel/docux/icons/check'
import Formbricks from '@theme/MDXComponents/Formbricks'

# Static Routes in Cloud Platform Networks

You can use static routing if there is a device in the cloud subnet that acts as a router. You can:

* [configure static routes in a subnet](#configure-static-routing-on-subnet) where devices, such as cloud servers, are located; ;
* [configure static routes on a cloud router](#configure-static-routing-on-cloud-router).

To configure static routes on a global router, follow the instructions in [Configure Routing on a Global Router](/global-router/create-network/create-global-router-network.mdx#configure-routing-on-global-router).

## Examples of use cases \{#tasks-to-be-solved}

### Internet access for a network connected to a global router \{#internet-access-for-network-connected-to-global-router}

For example, a private Cloud Platform network is connected to a global router, and you need to:

* configure internet access for cloud servers located in subnets of this private network;
* configure internet access for a private Managed Kubernetes cluster subnet to deploy nodes;
* use a public floating IP address for a cloud server or a load balancer in a private network;
* use a cloud router as a gateway for internet access for servers or hosts from other pools and services.

### Sending traffic through a cloud server (proxy) \{#sending-traffic-through-cloud-server}

If you need to send traffic to other subnets, you can use a cloud server as a gateway and configure static routing. For example:

* configure internet access from a subnet;
* configure connectivity with external infrastructure via VPN.

## Configure static routes in a subnet \{#configure-static-routing-on-subnet}

The following can be used as the source subnet:

* a private subnet;
* public subnet — only via OpenStack CLI;
* private networks and public subnets that have access configured in different projects (with the **Cross-project** tag) — only via OpenStack CLI.

You cannot set a metric (route weight or cost) for a static route, so it is impossible to configure two or more routes with the same source and destination subnets.

<Tabs queryString="configure-static-routing-on-subnet">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    When configuring a static route in the Control panel, only a private subnet can be selected as the source subnet.

    1. In the [Control panel](https://my.selectel.ru/vpc/default/networks/), on the top menu, click **Products** and select **Cloud Servers**.
    2. Go to the **Network** section → **Private Networks** tab.
    3. Open the private network page → **Subnets** tab.
    4. In the subnet card, open the **Automatic Network Settings** block.
    5. Click **Add route**.
    6. Enter the destination subnet CIDR — this is the subnet to which traffic will be directed.
    7. Enter the gateway (next-hop) — the IP address through which devices in the source subnet will direct traffic to the destination subnet. You can enter any address from the source subnet.
    8. Click <CheckIcon />.
    9. Apply the changes. To do this, [update the network settings on the devices in the subnet](/cloud-servers/cloud-networks/update-network-settings.mdx).
  </TabItem>

  <TabItem value="openstack">
    <TabItemLabel>
      OpenStack CLI
    </TabItemLabel>

    When configuring a static route via OpenStack CLI, you can select either a private or a public subnet as the source subnet.

    1. [Open the OpenStack CLI](/cloud-servers/tools/openstack-cli/).

    2. Configure a static route:

       ```bash
       openstack subnet set \
         --host-route destination=<destination_subnet_cidr>,gateway=<next_hop_ip_address> \
         <subnet>
       ```

       Specify:

       * `<destination_subnet_cidr>` — the CIDR of the destination subnet to which traffic will be directed, for example, `172.16.0.8/29`;
       * `<next_hop_ip_address>` — the gateway (next-hop) — the IP address through which devices in the source subnet will direct traffic to the destination subnet. You can enter any address from the source subnet;
       * `<subnet>` — the ID or name of the source subnet, which can be viewed using the `openstack subnet list` command.

       If you have previously configured static routes and want to delete all routes and add a new one at the same time, use the `--no-host-route:` parameter:

       ```bash
       openstack subnet set \
         --no-host-route \
         --host-route destination=<destination_subnet_cidr>,gateway=<next_hop_ip> \
         <subnet>
       ```

    3. Verify that the static route has been added. To do this, check the `destination` (destination subnet) and `gateway` (next-hop) parameters in the command output:

       ```bash
       openstack subnet show <subnet>
       ```

    4. Apply the changes. To do this, [update the network settings on the devices in the subnet](/cloud-servers/cloud-networks/update-network-settings.mdx).
  </TabItem>
</Tabs>

## Configure static routes on a cloud router \{#configure-static-routing-on-cloud-router}

<Tabs queryString="configure-static-routing-on-cloud-router">
  <TabItem value="openstack" default>
    <TabItemLabel>
      OpenStack CLI
    </TabItemLabel>

    1. [Open the OpenStack CLI](/cloud-servers/tools/openstack-cli/).
    2. Configure a static route:

       ```bash
       openstack router add route \
         --route destination=<destination_subnet_cidr>,gateway=<next_hop_ip_address> \
         <router>
       ```

       Specify:

       * `<destination_subnet_cidr>` — the CIDR of the destination subnet to which traffic will be directed, for example, `172.16.0.8/29`;
       * `<next_hop_ip_address>` — the gateway (next-hop) — the router IP address through which traffic will be directed to the destination subnet. The subnet with the router must be [connected to the cloud router](/cloud-servers/cloud-networks/cloud-routers.mdx#connect-private-subnet-to-cloud-router). The router address must not match the cloud router IP address;
       * `<router>` — the ID or name of the cloud router, which can be viewed using the `openstack router list` command.
  </TabItem>
</Tabs>

<Formbricks />
