A route table consists of route entries. Each route entry 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.
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.
Create a custom route table
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.
Add and delete route entries
Before you add or delete route entries, take note of the following limits:- After you create a VPC, the system creates a system route table for the VPC and adds system route entries to the route table. The system route entries are used to route traffic within the VPC. You cannot create or delete system route entries. However, you can create custom route entries to route traffic from specified CIDR blocks to specified destinations.
- Both system route tables and custom route tables allow you to add and delete custom route entries.
- Log on to the VPC console.
- In the left-side navigation pane, click Route Tables.
- In the top navigation bar, select the region to which the route table belongs.
- On the Route Tables page, find the route table that you want to manage and click its ID.
- On the details page of the route table, click the Route Entry List tab. On the Route Entry List tab, you can perform the following operations:
- Add a custom route entry
Click the Custom Route tab and then click Add Route Entry. In the Add Route Entry panel, set the following parameters and click OK.
Parameter Description Name Enter a name for the custom route entry. The name must be 2 to 128 characters, and can contain digits, underscores (_), and hyphens (-). The name must start with a letter.
Destination CIDR Block Enter the CIDR block to which network traffic is forwarded. Note If the selected route table is a system route table and the region to which the route table belongs supports IPv6, you can set Destination CIDR Block to IPv6 CIDR Block or IPv4 CIDR Block. For more information about the regions that support IPv6 CIDR blocks, see Regions that support VPC features.Next Hop Type Select the next hop type. Valid values: - ECS Instance: Traffic destined for the specified CIDR block is routed to the specified ECS instance.
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.
- HaVip: Traffic destined for the specified CIDR block is routed to the high-availability virtual IP address (HAVIP) that you select.
- VPN Gateway: Traffic destined for the specified CIDR block is routed to the specified VPN gateway.
- NAT Gateway: Traffic destined for the specified CIDR block is routed to the specified NAT gateway.
- Secondary ENI: Traffic destined for the specified CIDR block is routed to the specified secondary elastic network interface (ENI).
- Transit Router: Traffic destined for the specified CIDR block is routed to the specified transit router. For more information about transit routers, see How transit routers work.
- IPv6 Gateway: Traffic destined for the specified CIDR block is routed to the specified IPv6 gateway.
Note If the selected route table is a system route table, the region to which the route table belongs supports IPv6, and Destination CIDR Block is set to IPv6 CIDR Block, you can set Next Hop Type to IPv6 Gateway, ECS Instance, or Secondary ENI.
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 Secondary ENI.
ECS Instance, HaVip, VPN Gateway, NAT Gateway, Secondary 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.
- ECS Instance: Traffic destined for the specified CIDR block is routed to the specified ECS instance.
- Delete a custom route entry
- Find the custom route entry that you want to delete and click Delete in the Actions column.
- In the Delete Route Entry message, click OK.
- Add a custom route entry
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. Subnet routes help you manage network traffic with more flexibility.
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.
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.
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.
- Log on to the VPC console.
- In the left-side navigation pane, click Route Tables.
- In the top navigation bar, select the region to which the route table belongs.
- On the Route Tables page, find the route table that you want to delete and click Delete in the Actions column.
- In the Delete Route Table message, click OK.
References
- DescribeRouteTableList: queries route tables.
- CreateRouteTable: creates a custom route table.
- ModifyRouteTableAttributes: modifies the name and description of a specified route table.
- CreateRouteEntry: creates a custom route entry.
- DeleteRouteEntry: deletes a custom route entry.
- AssociateRouteTable: associates a custom route table with a vSwitch in the same VPC.
- UnassociateRouteTable: disassociates a route table from a vSwitch.
- DeleteRouteTable: deletes a custom route table.