Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Virtual Private Cloud
  • Getting started
    • All guides
      • Creating a static route
      • Creating and setting up a NAT gateway
      • Getting NAT gateway info
      • Moving a route table between folders
      • Getting route table info
      • Moving a NAT gateway between folders
      • Deleting a route table
      • Deleting a NAT gateway
    • Enabling a software-accelerated network
    • Chart of network connections
    • Viewing operations with resources
  • DDoS Protection
  • Access management
  • Pricing policy
  • Terraform reference
  • Audit Trails events
  • Release notes
  • FAQ
  1. Step-by-step guides
  2. Static routing
  3. Creating a static route

Creating a static route

Written by
Yandex Cloud
Improved by
Danila N.
Updated at May 20, 2026

Note

VMs with public IP addresses use the default static route (0.0.0.0/0). If you need to create a NAT instance, create it in a separate subnet.

Management console
CLI
Terraform
API

To create a route table with static routes:

  1. In the management console, select the folder where you need to create a static route.

  2. Go to Virtual Private Cloud.

  3. In the left-hand panel, select Routing tables.

  4. Click Create.

  5. Enter a name for the route table. Follow these naming requirements:

    • Length: between 3 and 63 characters.
    • It can only contain lowercase Latin letters, numbers, and hyphens.
    • It must start with a letter and cannot end with a hyphen.
  6. (Optional) Add a description of a route table.

  7. Select the network to create the route table in.

  8. Click Add.

  9. In the window that opens, enter the destination subnet prefix in CIDR notation.

  10. Specify the Next hop, which is an IP address from the allowed ranges.

  11. Click Add.

  12. Click Create routing table.

To use static routes, associate the route table with a subnet:

  1. In the left-hand panel, select Subnets.
  2. In the row with the subnet, click .
  3. In the menu that opens, select Link routing table.
  4. In the window that opens, select your route table from the list.
  5. Click Link.

To create a route table with static routes:

  1. View the description of the CLI command for creating route tables:

    yc vpc route-table create --help
    
  2. Get your cloud network ID:

    yc vpc network list
    

    Result:

    +----------------------+-----------------+
    |          ID          |      NAME       |
    +----------------------+-----------------+
    | enp34hbpj8dq******** | yc-auto-subnet  |
    | enp846vf5fus******** | routes-test     |
    +----------------------+-----------------+
    
  3. Create a route table in one of the networks:

    yc vpc route-table create \
      --name=<table_name> \
      --network-id=<network_ID> \
      --route destination=<destination_prefix>,next-hop=<internal_IP_address>
    

    Where:

    • --name: Name of the route table.

    • --network-id: ID of the network where the table will be created.

    • --route: Route settings, which include these two parameters:

      • destination: Destination subnet prefix in CIDR notation, e.g., 0.0.0.0/0.
      • next-hop: Internal IP address of the VM from the allowed ranges the traffic will be sent through, e.g., 192.168.1.5.

    Result:

    ...done
    id: enpsi6b08q2v********
    folder_id: b1gqs1teo2q2********
    created_at: "2019-06-24T09:57:54Z"
    name: test-route-table
    network_id: enp846vf5fus********
    static_routes:
    - destination_prefix: 0.0.0.0/0
      next_hop_address: 192.168.1.5
    

Link your route table to a subnet that will use its static routes:

  1. Get a list your cloud subnets:

    yc vpc subnet list
    

    Result:

    +----------------------+------------------+----------------------+----------------+---------------+------------------+
    |          ID          |       NAME       |      NETWORK ID      | ROUTE TABLE ID |     ZONE      |      RANGE       |
    +----------------------+------------------+----------------------+----------------+---------------+------------------+
    | b0cf2b0u7nhl******** | subnet-1         | enp846vf5fus******** |                | ru-central1-a | [192.168.0.0/24] |
    +----------------------+------------------+----------------------+----------------+---------------+------------------+
    
  2. Associate the route table with one of the subnets:

    yc vpc subnet update <subnet_ID> \
      --route-table-id <route_table_ID>
    

    Result:

    ..done
    id: b0cf2b0u7nhl********
    folder_id: b1gqs1teo2q2********
    created_at: "2019-03-12T13:27:22Z"
    name: subnet-1
    network_id: enp846vf5fus********
    zone_id: ru-central1-a
    v4_cidr_blocks:
    - 192.168.0.0/24
    route_table_id: enp1sdveovdp********
    

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the relevant documentation on the Terraform website or its mirror.

If you do not have Terraform yet, install it and configure the Yandex Cloud provider.

To create a route table with static routes:

  1. In the configuration file, describe the resources you want to create:

    • name: Route table name. Use the following name format:

      • Length: between 3 and 63 characters.
      • It can only contain lowercase Latin letters, numbers, and hyphens.
      • It must start with a letter and cannot end with a hyphen.
    • network_id: ID of the network to host the table.

    • static_route: Static route description:

      • destination_prefix: Destination subnet prefix in CIDR notation.
      • next_hop_address: Gateway VM internal IP address serving as the next hop for the allowed traffic.

    Here is an example of the configuration file structure:

    resource "yandex_vpc_route_table" "test-route-table" {
    name       = "<route_table_name>"
      network_id = "<network_ID>"
      static_route {
        destination_prefix = "<destination_prefix>"
        next_hop_address   = "<internal_IP_address>"
      }
    }
    

    To add, update, or delete a route table, use the yandex_vpc_route_table resource indicating the network in the network_id field, e.g., network_id = yandex_vpc_network.test_route_table.id.

    For more information about the yandex_vpc_route_table properties in Terraform, see this provider guide.

  2. Make sure the configuration files are correct.

    1. In the terminal, navigate to the directory where you created your configuration file.

    2. Run a check using the following command:

      terraform plan
      

    If your configuration is correct, the terminal will display a list of the resources to be created and their settings. Otherwise, Terraform will show any detected errors.

  3. Deploy the cloud resources.

    1. If the configuration is correct, run this command:

      terraform apply
      
    2. Confirm creating the resources: type yes and press Enter.

      This will create all the resources you need in the specified folder. You can see their detailed description using the management console or this CLI command:

      yc vpc route-table list
      

      Result:

      +----------------------+-----------------------+-------------+----------------------+
      |          ID          |         NAME          | DESCRIPTION |      NETWORK-ID      |
      +----------------------+-----------------------+-------------+----------------------+
      | enpahlhr1vnl******** | terraform-route-table |             | enp0asmd9pr9******** |
      +----------------------+-----------------------+-------------+----------------------+
      

To create a route table and add static routes to it, use the create REST API method for the RouteTable resource or the RouteTableService/Create gRPC API call, and provide the following in the request:

  • ID of the folder the route table will reside in, in the folderId parameter.

  • Route table name in the name parameter. Follow these naming requirements:

    • Length: between 3 and 63 characters.
    • It can only contain lowercase Latin letters, numbers, and hyphens.
    • It must start with a letter and cannot end with a hyphen.
  • ID of the network the route table will reside in, in the networkId parameter.

  • Destination subnet prefix in CIDR notation in the staticRoutes[].destinationPrefix parameter.

  • Internal IP address of the VM the traffic will be routed through in the staticRoutes[].nextHopAddress parameter. The IP address must be within the allowed range.

To use static routes, associate the route table with a subnet. Use the update REST API method for the Subnet resource or the SubnetService/Update gRPC API call and provide the following in the request:

  • Subnet ID in the subnetId parameter.

    To get the subnet ID, use the list REST API method for the Subnet resource or the SubnetService/List gRPC API call and provide the folder ID in the folderId request parameter.

    To learn how to find out the folder ID, see Getting the folder ID.

  • Route table ID in the routeTableId parameter.

  • Name of the routeTableId parameter in the updateMask parameter.

Warning

The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask parameter as a single comma-separated string.

ExampleExample

Create a route table and associate it with your subnet. The example uses the following properties:

  • Folder ID: b1g681qpemb4********
  • Network ID: enp846vf5fus********
  • Subnet ID: b0cf2b0u7nhl********
  • Route table name: test-route-table
  • Destination subnet prefix: 0.0.0.0/0
  • Internal IP address: 192.168.1.5
CLI
Terraform
API
  1. Create a route table:

    yc vpc route-table create \
      --name=test-route-table \
      --network-id=enp846vf5fus******** \
      --route destination=0.0.0.0/0,next-hop=192.168.1.5
    
  2. Associate the route table with your subnet:

    yc vpc subnet update b0cf2b0u7nhl******** \
      --route-table-id enp1sdveovdp********
    
  1. In the configuration file, list the route table properties and specify route_table_id for your subnet:

    resource "yandex_vpc_route_table" "test_route_table" {
      name       = "test-route-table"
      network_id = "enp846vf5fus********"
      static_route {
        destination_prefix = "0.0.0.0/0"
        next_hop_address   = "192.168.1.5"
      }
    }
    
    resource "yandex_vpc_subnet" "example_subnet" {
      name           = "example-subnet"
      network_id     = "enp846vf5fus********"
      zone           = ru-central1-a
      v4_cidr_blocks = ["10.2.0.0/16"]
      # Associating the route table with the subnet
      route_table_id = yandex_vpc_route_table.test_route_table.id
    }
    

    For more information about the resources you can create with Terraform, see this provider guide.

  2. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  3. Apply the changes.

    1. Run this command to view the planned changes:

      terraform plan
      

      If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

  1. To create a route table, use the create REST API method for the RouteTable resource or the RouteTableService/Create gRPC API call, and provide the following in the request body:

    {
      "folderId": "b1g681qpemb4********",
      "name": "test-route-table",
      "networkId": "enp846vf5fus********",
      "staticRoutes": [
        {
          "destinationPrefix": "0.0.0.0/0",
          "nextHopAddress": "192.168.1.5"
        }
      ]
    }
    
  2. To associate a route table with a subnet, use the update REST API method for the Subnet resource or the SubnetService/Update gRPC API call, and provide the following in the request body:

    {
      "updateMask": "routeTableId",
      "subnet": {
        "routeTableId": "enpfs106jh40********"
      }
    }
    

Was the article helpful?

Previous
Deleting an internal IP address
Next
Creating and setting up a NAT gateway
© 2026 Direct Cursus Technology L.L.C.