Route Table Usage Guidelines
Route Table Overview

- Default route table: When you create a VPC, the system automatically generates a default route table for the VPC. If you create a subnet in the VPC, the subnet is automatically associated with the default route table. The default route table ensures that subnets in a VPC can communicate with each other.
- Custom route table: If you do not want to use the default route table, you can create a custom route table and associate it with the subnet. Custom route tables can be deleted if they are no longer required.
A custom route table associated with a subnet only affects the outbound traffic. The default route table controls the inbound traffic.
Route Overview
You can add routes to default and custom route tables and configure the destination, next hop type, and next hop in the routes to determine where network traffic is directed. Routes are classified into system routes and custom routes.
- System routes: Routes that are automatically added by the system. They cannot be modified or deleted. System routes allow instances in a VPC to communicate with each other.
- Custom routes: Routes that can be modified and deleted. The destination of a custom route cannot overlap with that of a system route.
You cannot add two routes with the same destination to a VPC route table even if their next hop types are different, because the destination determines the route priority. If this happens, the destination with the closest match is preferentially selected based on the longest prefix match rule.
How Route Tables Work
Each subnet in a VPC must have a route table associated. A subnet can be associated with the default route table or a custom route table.
- Subnet 1 is associated with the default route table that contains a route pointing to the VPN gateway. This route allows ECSs in subnet 1 to access the on-premises data center through VPN.
- Subnet 2 is associated with a custom route table that contains a route pointing to the NAT gateway. This route allows ECSs in subnet 2 to access the Internet through the NAT gateway and EIP.
Route Priority
No. |
Route Type |
Description |
---|---|---|
1 |
Local route |
Local routes are system routes used for communications within a VPC and have the highest priority. |
2 |
Specific route |
Excepting local routes, if there are multiple routes that match the request destination, the longest prefix match is used. This means that the route with the longest subnet mask is preferentially used to determine the next hop. For example, if the destination of traffic entering a VPC is 192.168.1.12/32, the VPC route table has the following routes:
According to the longest prefix match, the request preferentially matches route B and will be forwarded to the VPC peering connection. |
3 |
EIP route |
If an ECS in a subnet has an EIP bound, the EIP route takes precedence over the default route (destination: 0.0.0.0/0) in the route table. In this case, the EIP is used to access the Internet.
Example:
In this case, ECS-A will use the EIP to access the Internet instead of the NAT gateway. |
4 |
Default route |
The route with the destination 0.0.0.0/0 is the default route, which can match any traffic. According to the longest prefix match, 0.0.0.0/0 has the lowest priority. |
Huawei Cloud provides various services to connect VPCs in different scales and scenarios.
Enabling Communications Between VPCs Using a VPC Peering Connection and Routes
Enabling Communications Between VPCs Using an Enterprise Router and Routes
Enabling ECSs in a VPC to Access the Internet Using a NAT Gateway and Routes
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot