Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Virtual Private Cloud
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Cloud network
      • Creating a cloud network
      • Deleting a cloud network
      • Updating a cloud network
    • Subnet
      • Creating a subnet
      • Deleting a subnet
      • Updating a subnet
    • IP address
      • Reserving a static public IP address
      • Making a dynamic public IP address static
      • Making a static public IP address dynamic
      • Deleting a static public IP address
    • Static routes
      • Creating a static route
      • Enabling NAT to the internet
    • Security groups
      • Create a security group
      • Update a security group and rules
      • Delete a security group
    • DDoS Protection
      • Enable protection from DDoS attacks
  • Use cases
    • Architecture and protection of a basic internet service
  • Concepts
    • Relationship between service resources
    • Cloud networks and subnets
    • Cloud resource addresses
    • Static routes
    • Security groups
    • MTU and MSS
    • DHCP settings
    • Quotas and limits
  • DDoS Protection
  • Cloud Interconnect
  • Access management
  • Pricing policy
    • Current policy
    • Archive
      • Policy before January 1, 2019
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • AddressService
      • NetworkService
      • RouteTableService
      • SecurityGroupService
      • SubnetService
      • OperationService
    • REST
      • Overview
      • Address
        • Overview
        • create
        • delete
        • get
        • getByValue
        • list
        • listOperations
        • update
      • Network
        • Overview
        • create
        • delete
        • get
        • list
        • listOperations
        • listSubnets
        • move
        • update
      • RouteTable
        • Overview
        • create
        • delete
        • get
        • list
        • listOperations
        • move
        • update
      • SecurityGroup
        • Overview
      • Subnet
        • Overview
        • create
        • delete
        • get
        • list
        • listOperations
        • move
        • update
      • Operation
        • Overview
        • get
  • Questions and answers
  1. Step-by-step instructions
  2. Static routes
  3. Creating a static route

Creating static routes

    Note

    The default static route (0.0.0.0/0) is used for VMs with public IPs. If you need to create a NAT instance, create it in a separate subnet.

    Management console
    CLI

    To create a route table and add static routes:

    1. Open the Virtual Private Cloud section in the folder where you want to create a static route.

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

    3. Click Create route table.

    4. Enter a name for the route table.

      • The name must be unique within the folder.
      • The name may contain lowercase Latin letters, numbers, and hyphens.
      • The first character must be a letter. The last character can't be a hyphen.
      • The maximum length of the name is 63 characters.
    5. Click Add route.

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

    7. Specify the next hop, which is an IP address from the allowed ranges.

    8. Click Add.

    9. Click Create route table.

    To use static routes, link the route table to a subnet:

    1. In the line with the desired subnet, click .
    2. In the menu that opens, select Link route table.
    3. In the window that opens, select the created table from the list.
    4. Click Add.

    To create a route table and add static routes:

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

      $ yc vpc route-table create --help
      
    2. Get the IDs of cloud networks in your cloud:

      $ yc vpc network list
      +----------------------+-----------------+
      |          ID          |      NAME       |
      +----------------------+-----------------+
      | enp34hbpj8dqebn3621l | yc-auto-subnet  |
      | enp846vf5fus0nt3lu83 | routes-test     |
      +----------------------+-----------------+
      
    3. Create a routing table in one of the networks. Use the following flags:

      • name — The name of the route table.
      • network-id — The ID of the network where the tables will be created.
      • route — The route settings with two parameters:
        • destination — The destination subnet prefix in CIDR notation.
        • next-hop — The internal IP address of the VM from the allowed ranges that traffic is sent through.
      $ yc vpc route-table create --name=test-route-table --network-id=enp846vf5fus0nt3lu83 --route destination=0.0.0.0/0,next-hop=192.168.1.5
      ...done
      id: enpsi6b08q2vfdmppsnb
      folder_id: b1gqs1teo2q2a4vnmi2t
      created_at: "2019-06-24T09:57:54Z"
      name: test-route-table
      network_id: enp846vf5fus0nt3lu83
      static_routes:
      - destination_prefix: 0.0.0.0/0
        next_hop_address: 192.168.1.5
      

    To use static routes, link the route table to a subnet:

    1. Get a list of subnets in your cloud:

      $ yc vpc subnet list
      +----------------------+------------------+----------------------+----------------+---------------+------------------+
      |          ID          |       NAME       |      NETWORK ID      | ROUTE TABLE ID |     ZONE      |      RANGE       |
      +----------------------+------------------+----------------------+----------------+---------------+------------------+
      | b0cf2b0u7nhl75gp1c9t | subnet-1         | enp846vf5fus0nt3lu83 |                | ru-central1-c | [192.168.0.0/24] |
      | e2llnffvbakqu18hr170 | subnet-2         | enp846vf5fus0nt3lu83 |                | ru-central1-b | [192.168.1.0/24] |
      +----------------------+------------------+----------------------+----------------+---------------+------------------+
      
    2. Link the routing table to one of the subnets:

      $ yc vpc subnet update b0cf2b0u7nhl75gp1c9t --route-table-id enp1sdveovdpdhaao5dq
      ..done
      id: b0cf2b0u7nhl75gp1c9t
      folder_id: b1gqs1teo2q2a4vnmi2t
      created_at: "2019-03-12T13:27:22Z"
      name: subnet-1
      network_id: enp846vf5fus0nt3lu83
      zone_id: ru-central1-c
      v4_cidr_blocks:
      - 192.168.0.0/24
      route_table_id: enp1sdveovdpdhaao5dq
      
    Language
    Careers
    Privacy policy
    Terms of use
    © 2021 Yandex.Cloud LLC