Help Center> Virtual Private Cloud> User Guide> Route Table> Example Custom Route in a VPC

Example Custom Route in a VPC

A custom route in a VPC routes traffic originating from ECSs in a VPC to a specified ECS also in that VPC. A custom route in a VPC can be used in the following scenarios:

  • When ECSs in a VPC need to access the Internet, add a custom route to enable the ECSs to access the Internet through the ECS that has an EIP bound. When adding the custom route, set Destination to the default value 0.0.0.0/0 and Next Hop to the private or virtual IP address of the ECS that has an EIP bound in the VPC.
  • When ECSs in a VPC need to access the container network, add a route to enable the ECSs to access the container network through an ECS with the container network configured. When adding the custom route, set Destination to default value 0.0.0.0/0 or a network segment on the container network and Next Hop to the private or virtual IP address of the ECS with the container network configured in the VPC.

The destination of each route must be unique.

Accessing the Internet Through a Custom Route

Example scenario

There are two ECSs in a VPC, ECS1 and ECS2. ECS1 has an EIP bound, but ECS2 does not. You can add a custom route to enable ECS2 to access the Internet through ECS1.

Figure 1 Accessing the Internet through a custom route

Configuration

  1. Table 1 lists the example custom route configuration. The destination is default value 0.0.0.0/0, and the next hop is the ECS1 private or virtual IP address bound with an EIP.
    Table 1 Custom route

    Destination

    Next Hop

    0.0.0.0/0

    ECS1 private or virtual IP address

    • 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.
  2. Configure ECS1 as an SNAT server by following the instructions provided in Configuring an SNAT Server.

Accessing the Container Network on an ECS Through a Custom Route

Example scenario

There are two ECSs in a VPC, ECS1 and ECS2, and a container network has been configured for ECS1. If ECS2 needs to access the container network, you can add a custom route.

Figure 2 Accessing the container network on an ECS through a custom route

Configuration

  1. When adding the custom route, set Destination to default value 0.0.0.0/0 or a network segment on the container network and Next Hop to the private or virtual IP address of the ECS with the container network configured in the VPC.
    Table 2 Custom route

    Destination

    Next Hop

    0.0.0.0/0

    The private or virtual IP address of ECS1

  2. Configure ECS1 as an SNAT server by following the instructions provided in Configuring an SNAT Server.