All Products
Search
Document Center

Virtual Private Cloud:Use custom route tables to manage network traffic

Last Updated:Mar 25, 2025

You can create a custom route table in a virtual private cloud (VPC), add custom routes, and associate the table with a vSwitch to manage traffic and network flexibly.

Limits

  • Each VPC can have at most 10 route tables, which include the system route table but exclude gateway route tables.

  • Each vSwitch can be associated with only one route table, whether it is a system route table or a custom one.

Prerequisite

A VPC and a vSwitch have been created. For more information, see Create a VPC with an IPv4 CIDR block.

Procedure

Step 1: 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.

  4. On the Route Tables page, click Create Route Table.

  5. On the Create Route Table page, set the following parameters and click OK.

    • VPC: Select the VPC to which the custom route table belongs.

    • Associated Resource Type: Select the type of resource with which you want to associate the route table.

      • vSwitch: Controls traffic routing policies.

      • Border Gateway: Controls inbound traffic routing policies of border gateway.

    On the Route Tables page, you can view route tables classified as Custom, which is in the Route Table Type column. The following system routes are automatically added to the custom route table:

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

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

Step 2: Add a custom route to the custom route table

Note
  • The system automatically creates a system route table for each VPC and adds route entries to manage traffic. These entries cannot be manually created or deleted.

  • You can add or delete custom route tables in both system and custom route tables to enable traffic routing to a specific CIDR block.

  • Custom route entries cannot have a destination CIDR block that is more specific than the CIDR block of the vSwitch.

  1. On the Route Tables page, find the custom route table that you want to manage and click its ID.

  2. On the details page, choose Route Entry List > Custom Route and click Add Route Entry.

  3. In the Add Route Entry dialog box, configure the following parameters and click OK.

    Parameter

    Description

    Destination CIDR Block

    Enter the destination CIDR block.

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

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

      Note

      When the route table is a system route table and the associated resource is a custom route table of a vSwitch, you can set Destination CIDR Block to IPv6 CIDR Block. For more information on the available regions, see Regions that support VPC features.

    • VPC Prefix List: The destination CIDR block is a prefix list.

    Next Hop Type

    Select a next hop type.

    • When the Destination CIDR Block is IPv4 CIDR Block or VPC Prefix List:

      Route the traffic directed to addresses that fall within the destination CIDR blocks to: IPv4 Gateway, NAT Gateway, VPC Peering Connection, Transit Router, VPN Gateway, ECS Instance, ENI, HaVip, Router Interface (to VBR), Router Interface (to VPC), ECR, and GWLB Endpoint.

    • When the Destination CIDR Block is IPv6 CIDR Block:

      Route the traffic directed to addresses that fall within the destination CIDR blocks to: ECS Instance, IPv6 Gateway, ENI, Router Interface (to VBR), ECR, VPC Peering Connection, GWLB Endpoint and Transit Router.

    Note

    Regions where you can modify the next hop to GWLB Endpoint are supported, see Regions and zones in which Gateway Load Balancer (GWLB) is available.

    After you specify the Next Hop Type, you can select an instance as the next hop. You can also go to the product page to create an instance.

Step 3: Associate the custom route table with a vSwitch

You can associate the custom route table with a vSwitch to manage the routes of the vSwitch.

Note
  • A route table can be associated with multiple vSwitches, but each vSwitch can only be linked to one route table at a time.

  • Associating a custom route table with a vSwitch automatically disassociates the system route table.

  • To disassociate a custom route table, use the Unbind option in the Actions column on the Associated vSwitch tab. The vSwitch will then revert to the system route table.

  • Custom route tables with a CIDR block matching a vSwitch cannot be associated with that vSwitch.

  1. On the Route Tables page, find the custom route table that you want to manage and click its ID.

  2. On the details page of the route table, click the Associated vSwitch tab and click Associate vSwitch.

  3. In the Associate vSwitch dialog box, choose the vSwitch that you want to associate.

    On the Associated 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 associated with the vSwitch is a custom route table.

Related steps

Modify system route entries

You can modify the next hop of system route entries in a custom route table to direct traffic to ECS Instance or ENI for dynamic traffic management.

Note
  • You cannot modify the next hops of system route entries in a system route table.

  • After associating a custom route table with a vSwitch, you cannot modify the next hop of the system route entry with the same Destination CIDR Block as the vSwitch. For example, if a custom route table is associated with a vSwitch with a CIDR block of 172.16.0.0/24, the next hop of the route entry with a Destination CIDR Block of 172.16.0.0/24 cannot be modified.

  • After the next hop type and associated resource of a system route entry are modified, the route entry is converted to a custom route entry under the Custom Route Entries tab.

  1. On the Route Tables page, select the desired route table instance by clicking its ID.

  2. Under the Route Entry List > System Route Entries tab, locate the system route entry to modify, and click Edit in the Actions column.

  3. In the Edit Route Table Entry dialog box, adjust the parameters as necessary.

    Parameter

    Description

    Destination CIDR Block

    Shows the destination CIDR block for traffic. The Destination CIDR Block is not modifiable.

    Next Hop Type

    The next hop types include Local, ECS Instance, or Elastic Network Interface or GWLB Endpoint.

    Regions where you can modify the next hop to GWLB Endpoint are supported, see Regions and zones in which GWLB is available.

    After you select a Next Hop Type, you must choose a specific instance from the corresponding list or create one through the product page.

Modify custom route entries

You can modify the next hop of custom route entries to manage network traffic and direct the traffic toward specific cloud resources.

Note

The next hop type of custom route entries with a Destination CIDR Block matching the CIDR block of a vSwitch in the VPC can only be changed to ECS Instance or Elastic Network Interface (ENI). For example, if a vSwitch has a CIDR block of 172.16.0.0/24, the next hop of the route entry with a Destination CIDR Block of 172.16.0.0/24 can be changed to an ECS Instance or Elastic Network Interface (ENI). Deleting the route entry reverts the route entry to a System Route Entry in the Local route tab.

  1. Navigate to the Route Tables page and click the ID of the route table you want to modify.

  2. Click the Route Entry List > Custom Route tab, find the custom route entry that you want to manage, and click Edit in the Actions column.

  3. In the Modify Route Table dialog box, update the following parameters:

    Parameter

    Description

    Destination CIDR Block

    The destination CIDR block is displayed and cannot be modified.

    Next Hop Type

    Select the next hop type from the available options.

    After you select a Next Hop Type, you must then select a specific instance from the drop-down list or create a new instance on the corresponding product page.

Delete custom route entries

You can delete custom route entries in the following two ways:

  • Individually: Find the custom route entry that you want to delete and click Delete in the Actions column.

  • In batch: Select all the custom route entries that you want to delete and click Delete at the bottom of the page.

Delete the custom route table

Note

Custom route tables can be deleted, whereas system route tables cannot. If a custom route table is associated with a vSwitch, you need to disassociate it before deletion.

On the Route Tables page, locate the custom route table to delete and click Delete in the Actions column.

References

You can also manage route tables by using SDKs, Terraform, or ROS. For more information, see the following documents: