Example Custom Route Outside a VPC
A custom route outside a VPC routes traffic originating outside the VPC to specified ECSs in the VPC. When adding this type of route, you can set Destination to the default value 0.0.0.0/0 or a specific network segment. However, the network segment cannot conflict with subnet CIDR blocks in the VPC. The destination of each custom route must be unique.
Custom Route Between VPCs
Example scenario
If a VPC peering connection has been created linking two VPCs, VPC1 and VPC2, but only VPC1 has Internet access, you can add a custom route to allow the ECSs in VPC2 to access the Internet through an ECS that has an EIP bound in VPC1.
Configuration
- Create a VPC peering connection between VPC1 and VPC2. Figure 2 shows the VPC peering connection configuration.
Table 1 and Table 2 list the routes used to configure the VPC peering connection.
Table 1 Route of a VPC peering connection in the route table associated with Subnet A Destination
Next Hop
192.168.10.0/24
pc-01
Table 2 Route of a VPC peering connection in the route table associated with Subnet X Destination
Next Hop
192.168.1.0/24
pc-01
0.0.0.0/0
pc-01
In the preceding route tables, value pc-01 indicates the VPC peering connection ID. The value is automatically generated and cannot be configured.
- Table 3 lists the custom route table configuration.
Table 3 Custom route in the VPC1 default route table Destination
Next Hop
0.0.0.0/0
The private or virtual IP address of ECS1
- When you use a custom route to access the Internet, the destination can only be set to default value 0.0.0.0/0. It cannot be set to a specific public network segment.
- If the next hop is a virtual IP address, the virtual IP address must have an EIP bound. Otherwise, access to the Internet through this virtual IP address is not possible.
- Configure ECS1 as an SNAT server by following the instructions provided in Configuring an SNAT Server.
Custom Route Between a VPC and a Direct Connect Connection
Example scenario
You can add a custom route to forward all packets from a Direct Connect connection to specified servers in the VPC, but a custom route needs to be added to the VPC. Table 4 provides the details needed to configure the route.
Configuration
- Table 4 lists the custom route configuration. The destination is default value 0.0.0.0/0, and the next hop is the ECS private or virtual IP address.
- Configure ECS1 as an SNAT server by following the instructions provided in Configuring an SNAT Server.
Last Article: Example Custom Route in a VPC
Next Article: Configuring an SNAT Server

Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.