You can create a custom route table in a virtual private cloud (VPC) and add custom routes to the custom route table. Then, you can associate the custom route table with a vSwitch to control the traffic of the vSwitch. This facilitates network management. The preceding operations are used to perform subnet routing.

Background information

Before you perform subnet routing, take note of the following limits:

  • Each VPC can contain at most 10 route tables including the system route table.
  • Each vSwitch can be associated with only one system route table or one custom route table.

Prerequisites

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

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.
    Area Region
    Asia Pacific China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Hangzhou), China (Shanghai), China (Nanjing-Local Region), China (Fuzhou-Local Region), China (Heyuan), China (Shenzhen), China (Guangzhou), China (Chengdu), China (Hong Kong), Japan (Tokyo), South Korea (Seoul), Singapore (Singapore), Australia (Sydney), Malaysia (Kuala Lumpur), Indonesia (Jakarta), Philippines (Manila), Thailand (Bangkok), and India (Mumbai)
    Europe & Americas Germany (Frankfurt), UK (London), US (Silicon Valley), and US (Virginia)
    Middle East UAE (Dubai)
  4. On the Route Tables page, click Create Route Table.
  5. On the Create Route Table page, set the following parameters and click OK.
    Parameter Description
    Resource Group Select the resource group to which the custom route table belongs.
    VPC Select the VPC to which the custom route table belongs.

    If the VPC contains an Elastic Compute Service (ECS) instance that belongs to one of the following instance families, you cannot create a custom route table for the VPC:

    ecs.c1, ecs.c2, ecs.c4, ecs.c5, ecs.ce4, ecs.cm4, ecs.d1, ecs.e3, ecs.e4, ecs.ga1, ecs.gn4, ecs.gn5, ecs.i1, ecs.m1, ecs.m2, ecs.mn4, ecs.n1, ecs.n2, ecs.n4, ecs.s1, ecs.s2, ecs.s3, ecs.se1, ecs.sn1, ecs.sn2, ecs.t1, and ecs.xn4.

    To create a custom route table, you must upgrade or release the ECS instances that do not support advanced VPC features.
    Note If your VPC contains ECS instances of the preceding instance families and a custom route table is created, you must upgrade or release the ECS instances. Otherwise, the custom route table cannot work as expected. For more information, see Advanced VPC features.
    Name Enter a name for the custom route table.
    Description Enter a description for the custom route table.
    After the custom route table is created, you can go to the Route Tables page to view the route table. Custom is displayed in the Route Table Type column of the route table. 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 within the VPC.
    • A route destined for the CIDR block of a vSwitch of the VPC to which the route table belongs. This route is used for communication between cloud resources within the vSwitch.
    For example, the CIDR block of your VPC is 192.168.0.0/16 and you created two vSwitches whose CIDR blocks are 192.168.1.0/24 and 192.168.0.0/24 in the VPC. The custom route table that you created for your VPC includes the following system routes. The "-" sign in the following table indicates the VPC.
    Destination CIDR Block Next Hop Type
    100.64.0.0/10 - System route
    192.168.1.0/24 - System route
    192.168.0.0/24 - System route

Step 2: Add a custom route to the 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 to which the custom route table belongs.
  4. On the Route Tables page, find the custom route table that you want to manage and click its ID.
  5. On the details page of the custom route table, choose Route Entry List > Custom Route, and click Add Route Entry.
  6. In the Add Route Entry panel, set the following parameters and click OK.
    Parameter Description
    Name Enter a name for the custom route.
    Destination CIDR Block Enter the CIDR block to which network traffic is forwarded.
    • IPv4 CIDR Block: The destination CIDR block is an IPv4 CIDR block.
    • IPv6 CIDR Block: The destination CIDR block is an IPv6 CIDR block.
      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. For more information about the regions that support IPv6 CIDR blocks, see Regions that support VPC features.
    • VPC Prefix List: The destination CIDR block belongs to a prefix list. For more information about prefix lists, see Overview of prefix lists.
    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. For more information about ECS instances, see What is ECS.

      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 specified high-availability virtual IP address (HAVIP). For more information about HAVIPs, see Overview of HAVIPs.
    • VPN Gateway: Traffic destined for the specified CIDR block is routed to the specified VPN gateway. For more information about VPN gateways, see What is VPN Gateway?.
    • NAT Gateway: Traffic destined for the specified CIDR block is routed to the specified NAT gateway. For more information about NAT gateways, see What is NAT Gateway?.
    • VPC Peering Connection: Traffic destined for the specified CIDR block is routed to the specified VPC peering connection. For more information about VPC peering connections, see Overview of VPC peering connections.
    • ENI: Traffic destined for the destination CIDR block is routed to the specified elastic network interface (ENI). For more information about ENIs, see Overview.
    • Router Interface (Border Router Direction): Traffic destined for the specified CIDR block is routed to the router interface that is associated with a virtual border router (VBR). For more information about router interfaces, see What is a VBR-to-VPC connection?.

      Select this type if you want to connect the VPC to a data center through Express Connect circuits.

      If you select Router Interface (Border Router Direction), you must also select a routing mode:

      • Common route: Select an associated router interface.
      • Primary/standby Route: Select two instances as the next hop. The active route has a weight of 100 and the standby route has a weight of 0. The standby route takes over when the active route fails to pass the health check.
      • Load routing: Select two to four router interfaces as the next hops. The peer router of each router interface must be a VBR. You can set the weight of each instance to an integer from 1 to 255. The default value is 100. The weights of the instances must be the same. This way, traffic can be evenly distributed to the next-hop instances.
    • 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. For more information about IPv6 gateways, see What is an 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 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 ENI.

    ECS Instance, HaVip, VPN Gateway, NAT Gateway, VPC Peering Connection, 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.

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. Each vSwitch can be associated with only one system route table or one 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 to which the route table belongs.
  4. On the Route Tables page, find the custom route table that you want to manage and click its ID.
  5. On the details page of the route table, click the Associated vSwitch tab and click Associate vSwitch.
  6. In the Associate vSwitch dialog box, select the vSwitch that you want to associate and click OK.
    On the Associated vSwitch tab, click the ID of the vSwitch that you associated with the route table in the vSwitch column. On the details page of the vSwitch, click the Route tab. In the Associated with Route Table section, you can view information about the custom route table that is associated with the vSwitch.