All Products
Search
Document Center

Virtual Private Cloud:Create and manage a route table

Last Updated:Feb 18, 2024

A route table consists of routes. Each route specifies the destination to which network traffic is routed. You can use a system route table to route traffic. You can also create a custom route table to manage network traffic.

Operations

View a route table associated with a vSwitch

You can view the information about a route table that is associated with a vSwitch in the Virtual Private Cloud (VPC) console.

  1. Log on to the VPC console.
  2. In the left-side navigation pane, click vSwitch.
  3. In the top navigation bar, select the region of the vSwitch with which the route table that you want to view is associated.

  4. On the vSwitch page, find the vSwitch that you want to manage and click its ID.
  5. In the vSwitch Basic Information section, click the Route tab. In the Associated with Route Table section, view the ID and type of the route table.

    Route tables are classified into the following types:

    • System: The vSwitch is associated with a system route table. To associate the vSwitch with a custom route table, click Bind next to the system route table. In the Associate Route Table dialog box, select the custom route table that you want to associate with the vSwitch.

    • Custom: The vSwitch is associated with a custom route table. To replace the custom route table, click Replace Associated Route Table and select another custom route table in the Associate Route Table dialog box.

Create a custom route table

  1. Log on to the VPC console.
  2. In the left-side navigation pane, click Route Tables.
  3. In the top navigation bar, select the region where you want to create a custom route table.

    Area Region
    Asia Pacific China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Hangzhou), China (Shanghai), China (Nanjing - Local Region), China (Fuzhou - Local Region), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Chengdu), China (Hong Kong), Japan (Tokyo), South Korea (Seoul), Singapore, Australia (Sydney), Malaysia (Kuala Lumpur), Indonesia (Jakarta), Philippines (Manila), Thailand (Bangkok), and India (Mumbai)
    Europe & Americas Germany (Frankfurt), UK (London), US (Silicon Valley), and US (Virginia)
    Middle East UAE (Dubai)
  4. On the Route Tables page, click Create Route Table.
  5. On the Create Route Table page, set the following parameters and click OK.

    Parameter

    Description

    Resource Group

    Select the resource group to which the custom route table belongs.

    VPC

    Select the VPC to which the custom route table belongs.

    If the VPC contains Elastic Compute Service (ECS) instances of the following instance families, you cannot create a custom route table for the VPC:

    ecs.c1, ecs.c2, ecs.c4, ecs.ce4, ecs.cm4, ecs.d1, ecs.e3, ecs.e4, ecs.ga1, ecs.gn4, ecs.gn5, ecs.i1, ecs.m1, ecs.m2, ecs.mn4, ecs.n1, ecs.n2, ecs.n4, ecs.s1, ecs.s2, ecs.s3, ecs.se1, ecs.sn1, ecs.sn2, ecs.t1, and ecs.xn4.

    To create a custom route table, you must upgrade or release the ECS instances that do not support advanced VPC features.

    Note

    If your VPC contains ECS instances of the preceding instance families and a custom route table is created, you must upgrade or release the ECS instances. Otherwise, the custom route table cannot work as expected. For more information, see Advanced VPC features.

    Name

    Enter a name for the custom route table.

    Description

    Enter a description for the custom route table.

    After the custom route table is created, you can go to the Route Tables page to view the route table. Custom is displayed in the Route Table Type column of the route table. The following system routes are automatically added to the custom route table:

    • A route entry whose destination CIDR block is 100.64.0.0/10. This route is used for communication among cloud resources within the VPC.

    • A route destined for the CIDR block of a vSwitch of the VPC to which the route table belongs. This route is used for communication between cloud resources within the vSwitch.

    For example, the CIDR block of your VPC is 192.168.0.0/16 and you created two vSwitches whose CIDR blocks are 192.168.1.0/24 and 192.168.0.0/24 in the VPC. The custom route table that you created for your VPC includes the following system routes. The "-" sign in the following table indicates the VPC.

    Destination CIDR block

    Next hop

    Type

    100.64.0.0/10

    -

    System route

    192.168.1.0/24

    -

    System route

    192.168.0.0/24

    -

    System route

Modify the basic information about a route table

You can modify the name and description of a system route table or a custom route table.

  1. Log on to the VPC console.
  2. In the left-side navigation pane, click Route Tables.
  3. In the top navigation bar, select the region to which the route table belongs.
  4. On the Route Tables page, find the route table that you want to manage and click its ID.
  5. On the details page of the route table, click Edit next to Name to modify the name of the route table.

  6. Click Edit next to Description to modify the description of the route table.

Add and delete routes

Before you add or delete routes, take note of the following limits:

  • After you create a VPC, the system creates a system route table for the VPC and adds system routes to the route table. The system routes are used to route traffic within the VPC. You cannot create or delete system routes. However, you can create custom routes to route traffic destined for specified CIDR blocks to specified destinations.

  • Both system route tables and custom route tables allow you to add and delete custom routes.

  1. Log on to the VPC console.
  2. In the left-side navigation pane, click Route Tables.
  3. In the top navigation bar, select the region to which the route table belongs.
  4. On the Route Tables page, find the route table that you want to manage and click its ID.
  5. On the details page of the route table, click the Route Entry List tab. Then, you can perform the following operations:

    • Add a custom route

      Click the Custom Route tab and then click Add Route Entry. In the Add Route Entry dialog box, set the following parameters and click OK.

      Parameter

      Description

      Name

      Enter a name for the custom route.

      Destination CIDR Block

      Enter a destination CIDR block.

      • IPv4 CIDR Block: The destination CIDR block is an IPv4 CIDR block.

      • IPv6 CIDR Block: The destination CIDR block is an IPv6 CIDR block.

        Note

        If the selected route table is a system route table and the object to be associated is a custom route table of a vSwitch, you can set Destination CIDR Block to IPv6 CIDR Block. For more information about the regions that support IPv6 CIDR blocks, see Regions that support VPC features.

      • VPC Prefix List: The destination CIDR block belongs to a prefix list. For more information, see Prefix list overview.

      Next Hop Type

      Select a next hop type. Valid values:

      The following types of next hop are supported if Destination CIDR Block is set to IPv4 CIDR Block or VPC Prefix List:

      • IPv4 Gateway: Traffic destined for the specified CIDR block is routed to a specified IPv4 gateway.

      • NAT Gateway: Traffic destined for the specified CIDR block is routed to a specified NAT gateway. For more information, see What is NAT Gateway?

      • VPC Peering Connection: Traffic destined for the specified CIDR block is routed to a specified VPC peering connection. For more information, see Overview of VPC peering connections.

      • Transit Router: Traffic destined for the specified CIDR block is routed to a specified transit router. For more information, see How transit routers work.

      • VPN Gateway: Traffic destined for the specified CIDR block is routed to a specified VPN gateway. For more information, see What is VPN Gateway?

      • ECS Instance: Traffic destined for the specified CIDR block is routed to a specified ECS instance. For more information, see What is ECS? Select this type if you want to route traffic to a specified ECS instance for centralized traffic forwarding and management. For example, you can configure an ECS instance as the Internet-facing gateway to route traffic from other ECS instances to the Internet.

      • ENI: Traffic destined for the destination CIDR block is routed to a specified elastic network interface (ENI). For more information, see ENI overview.

      • Router Interface (To VBR): Traffic destined for the specified CIDR block is routed to the router interface that is associated with a virtual border router (VBR). For more information, see Peering connections.

        Select this type if you want to connect the VPC to a data center through Express Connect circuits.

        If you select Router Interface (To VBR), you must also select a routing mode. Supported modes:

        • General Routing: Select an associated router interface.

        • Active/Standby Routes: Select two instances as the next hops. The active route has a weight of 100 and the standby route has a weight of 0. The standby route takes over if the active route fails health checks.

        • Load-Balancing Routes: Select two to eight instances as the next hops. The instances must have the same weight, which must be an integer from 0 to 255. Network traffic is evenly distributed to the next hops.

      • Router Interface (To VPC): Traffic destined for the specified CIDR block is routed to the VPC that you select. For more information, see What is a VPC?

      The following types of next hop are supported if you select a system route table, the region of the route table supports IPv6 CIDR blocks, and Destination CIDR Block is set to IPv6 CIDR Block:

      • ECS Instance: Traffic destined for the specified CIDR block is routed to a specified ECS instance. For more information, see What is ECS? Select this type if you want to route traffic to a specified ECS instance for centralized traffic forwarding and management. For example, you can configure an ECS instance as the Internet-facing gateway to route traffic from other ECS instances to the Internet.

      • IPv6 Gateway: Traffic destined for the specified CIDR block is routed to a specified IPv6 gateway. For more information, see What is an IPv6 gateway?

      • ENI: Traffic destined for the destination CIDR block is routed to a specified ENI. For more information, see ENI overview.

      • Router Interface (To VBR): Traffic destined for the specified CIDR block is routed to the router interface that is associated with a virtual border router (VBR). For more information, see Peering connections.

        Select this type if you want to connect the VPC to a data center through Express Connect circuits.

        If you select Router Interface (To VBR), you must also select a routing mode. Supported modes:

        • General Routing: Select an associated router interface.

        • Load-Balancing Routes: Select two to eight instances as the next hops. The instances must have the same weight, which must be an integer from 0 to 255. Network traffic is evenly distributed to the next hops.

      • VPC Peering Connection: Traffic destined for the specified CIDR block is routed to a specified VPC peering connection. For more information, see Overview of VPC peering connections.

      Resource Group

      Select the resource group to which the next hop belongs.

      This parameter is required only if you set Next Hop Type to ECS Instance or ENI.

      ECS Instance, HaVip, VPN Gateway, NAT Gateway, VPC Peering Connection, ENI, Transit Router, and IPv6 Gateway

      Select an instance from the drop-down list as the next hop.

      You can also go to the product page to create an instance.

    • Delete a custom route

      1. Find the custom route that you want to delete and click Delete in the Actions column.

      2. In the Delete Route Entry message, click OK.

    • Delete multiple custom routes at a time

      1. Select the custom routes that you want to delete and click Delete in the lower-left corner.

      2. In the Delete Route Entry message, click OK.

Associate a route table with a vSwitch

You can create a custom route table in a VPC and associate the route table with a vSwitch. This way, you can manage the routes of the vSwitch, which are called subnet routes. You can use subnet routes to manage network traffic in a more flexible manner.

You can associate a route table with multiple vSwitches. Each vSwitch can be associated with only one system route table or one custom route table. After a custom route table is associated with a vSwitch, the system route table is automatically disassociated from the vSwitch.

  1. Log on to the VPC console.
  2. In the left-side navigation pane, click Route Tables.
  3. In the top navigation bar, select the region to which the route table belongs.
  4. On the Route Tables page, find the custom route table that you want to manage and click its ID.
  5. On the details page of the route table, click the Associated vSwitch tab and click Associate vSwitch.

  6. In the Associate vSwitch dialog box, select the vSwitch that you want to associate and click OK.

    On the Associate vSwitch tab, click the vSwitch ID in the vSwitch column to go to the vSwitch details page. Then, click the Route tab. In the Associated with Route Table section, you can verify that the route table is a custom route table.

Disassociate a route table from a vSwitch

You can disassociate a custom route table from a vSwitch. After a custom route table is disassociated from a vSwitch, the vSwitch is automatically associated with the system route table.

  1. Log on to the VPC console.
  2. In the left-side navigation pane, click Route Tables.
  3. In the top navigation bar, select the region to which the route table belongs.
  4. On the Route Tables page, find the custom route table that you want to manage and click its ID.
  5. On the details page of the route table, click the Associated vSwitch tab, find the vSwitch that you want to manage and click Unbind in the Actions column.

  6. In the Disassociate Route Table message, click OK.

    After a custom route table is disassociated from a vSwitch, the vSwitch is automatically associated with the system route table.

Delete a custom route table

You can delete custom route tables. However, you cannot delete system route tables. If the custom route table that you want to delete is associated with a vSwitch, you must first disassociate the custom route table from the vSwitch.

  1. Log on to the VPC console.
  2. In the left-side navigation pane, click Route Tables.
  3. In the top navigation bar, select the region to which the route table belongs.
  4. On the Route Tables page, find the custom route table that you want to delete and click Delete in the Actions column.

  5. In the Delete Route Table message, click OK.

References