This topic describes how to work with route tables. A route table consists of route entries. Each route entry specifies the destination network to which network traffic is routed. You can create a custom route table to manage the inbound and outbound network traffic of subnets in a virtual private cloud (VPC).

Operations

View a route table associated with a vSwitch

You can view information about a route table that is associated with a vSwitch in the VPC console.

  1. Log on to the VPC console.
  2. In the left-side navigation pane, click vSwitches.
  3. Select the region where the vSwitch that is associated with the route table is deployed.
  4. On the vSwitches page, find the vSwitch and click its ID.
  5. In the vSwitch Basic Information section, you can view the ID and type of the route table.
    • System: The vSwitch is associated with a system route table.
    • Custom: The vSwitch is associated with a custom route table.

Create a custom route table

  1. Log on to the VPC console.
  2. In the left-side navigation pane, click Route Tables.
  3. Select the region where you want to create a custom route table.
    For more information about regions that support custom route tables, see Regions that support custom route tables.
  4. On the Route Tables page, click Create Route Table.
  5. In the Create Route Table dialog box, set the following parameters and click OK.
    Parameter Description
    Resource Group Select the resource group to which the route table belongs.
    VPC Select the VPC to which the route table belongs.

    If a 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.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 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 instance. Otherwise, the custom route table cannot work as expected. For more information, see Overview of VPC advanced features.
    Name Enter a name for the route table.

    The name must be 2 to 128 characters in length, and can contain digits, underscores (_), and hyphens (-). It must start with a letter.

    Description Enter a description for the route table.

    The description must be 2 to 256 characters in length and cannot start with http:// or https://.

    After you create custom route tables, you can go to the Route Tables page to view route tables whose Route Table Type is Custom.The following system route entries are automatically added to custom route tables:
    • A route destined for the CIDR block 100.64.0.0/10. This route is used for communication between 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, you have created two vSwitches whose CIDR blocks are 192.168.1.0/24 and 192.168.0.0/24. These vSwitches are deployed in the VPC whose CIDR block is 192.168.0.0/16. Custom route tables that you create for the VPC include the following route entries:
    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

Modify basic information about a 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 route table and click its ID.
  5. In the Route Table Details section, you can click Edit next to Name to modify the name of the route table.
    The name must be 2 to 128 characters in length and can contain digits, underscores (_), and hyphens (-). The name must start with a letter.
  6. Click Edit next to Description to modify the description of the route table.
    The description must be 2 to 256 characters in length, and cannot start with http:// or https://.

Create or delete route entries

  • After you create a VPC, the system creates a default route table and adds system route entries to the route table to manage traffic of the VPC. You cannot create or delete system route entries. However, you can create custom route entries to route traffic from source CIDR blocks to specific destinations. You can add custom route entries to both system and custom route tables.
  • You can delete custom route entries. However, you cannot delete system route entries.
  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 route table and click its ID.
  5. In the Route Table Details section, click the Route Entry List tab. On the tab, you can perform the following operations.
    • Add a custom route entry
      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 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 The destination CIDR block to which you want to route traffic.
      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 an ECS instance for centralized traffic forwarding and management. For example, when an ECS instance is configured as the public-facing gateway to manage the traffic from other ECS instances to the Internet.

      • HaVip Address: Traffic destined for the specified CIDR block is routed to the specified high-availability virtual IP address (HAVIP).
      • 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).
      Resource Group Select the resource group to which the next hop belongs.

      This parameter is required only when you set Next Hop Type to ECS Instance or Secondary ENI.

      ECS Instance/HaVip Address/VPN Gateway/NAT Gateway/Secondary Network Interface Select an instance as the next hop.
      • 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 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 The destination CIDR block to which you want to route traffic.
        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 an ECS instance for centralized traffic forwarding and management. For example, when an ECS instance is configured as the public-facing gateway to manage the traffic from other ECS instances to the Internet.

        • HaVip Address: Traffic destined for the specified CIDR block is routed to the specified high-availability virtual IP address (HAVIP).
        • 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 ENI.
        Resource Group Select the resource group to which the next hop belongs.

        This parameter is required only when you set Next Hop Type to ECS Instance or Secondary ENI.

        ECS Instance/HaVip Address/VPN Gateway/NAT Gateway/Secondary Network Interface Select an instance as the next hop.
      • You can click Export to export route entries to a CSV file.
    • Delete a custom route entry
      1. Find the custom route entry that you want to delete and click Delete in the Actions column.
      2. In the Delete Route Entry dialog box, click OK.

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. 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.

  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.
    For more information about the regions that support custom route tables, see Regions that support custom route tables.
  4. On the Route Tables page, find the route table and click its ID.
  5. In the Route Table Details section, click the Associated vSwitch tab and click Associate vSwitch.
  6. On the Associate vSwitch page, select the vSwitch that you want to associate and click OK.

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.

  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.
    For more information about the regions that support custom route tables, see Regions that support custom route tables.
  4. On the Route Tables page, find the route table and click its ID.
  5. In the Route Table Details section, click the Associated vSwitch tab. Find the vSwitch and click Unbind in the Actions column.
  6. In the Unbind Route Table dialog box, click OK.

Delete a custom route table

You can delete a custom route table. However, you cannot delete the system route table. 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.

  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 route table that you want to delete and click Delete in the Actions column.
  5. In the Delete Route Table message, click OK.