Create Routing Tables

Last updated: 2018-08-23 17:53:57

1. API Description

This API (CreateRouteTable) is used to create routing table.
Domain for API request:vpc.api.qcloud.com

When VPC has been created, the system will create a default routing table with which all new subnets will be associated. By default, you can use the default routing table to manage your routing policies. It you have many routing policies, you can call the API for creating routing table to create more routing tables to manage your routing policies.

2. Input Parameters

The following request parameter list only provides API request parameters. Common request parameters need to be added when the API is called. For more information, refer to Common Request Parameters. The Action field for this API is CreateRouteTable.

Parameter Name Required Type Description
vpcId Yes String ID of VPC to which the subnet belongs. It can be vpcId or unVpcId. unVpcId is recommended. For example, vpc-rqndayhs. It can be queried through API DescribeVpcEx.
routeTableName Yes String Routing table name. You can specify any name you like, but its length should be limited to 60 characters.
routeSet.n No array (Optional) Content of routing table.
routeSet.n.destinationCidrBlock Yes String Destination network segment, which cannot be within the VPC network segment. For example: 112.20.51.0/24.
routeSet.n.nextType Yes String Type of next hop. Supported types: 0: public network gateway; 1: VPN gateway; 3: Direct Connect gateway; 4: peering connection; 7: sslvpn; 8: NAT gateway; 9: general cvm .
routeSet.n.nextHub Yes String Next hop address. You just need to specify gateway IDs (new ID is recommended) of different next hop types and the system will automatically match to the next hop address.
routeSet.n.description No String Route description, which should be limited to 60 characters.

3. Output Parameters

Parameter Name Type Description
code Int Error code, 0: Succeeded, other values: Failed.
message String Error message.
routeTableId String Routing table ID, for example: gz_rtb_4545.
unRouteTableId String Unified ID of routing table. It is recommended to use a unified ID to identify the routing table, for example, rtb-rqndayhs.
routeTableSet.n Array Content of routing table.
routeTableSet.n.destinationCidrBlock String Destination network segment, which cannot be within the VPC network segment. For example: 112.20.51.0/24.
routeTableSet.n.nextType String Type of next hop. Supported types: 0: public network gateway; 1: VPN gateway; 3: Direct Connect gateway; 4: peering connection; 7: sslvpn; 8: nat gateway; 9: general cvm .
routeTableSet.n.nextHub String Next hop address. You just need to specify the gateway ID (new ID is recommended) of a different next hop type and the system will automatically match to the next hop address.
routeTableSet.n.description String Route description.

4. Error Codes

The following error code list only provides the business logic error codes for this API. For additional common error codes, refer to VPC Error Codes.

Error Code Description
InvalidVpc.NotFound Invalid VPC. VPC resource does not exist. Please verify that you have entered resource information correctly. You can query VPC through API DescribeVpcEx.
InvalidRouteTableName Invalid routing table name. You can specify any name you like, but its length should be limited to 60 characters.
InvalidDestinationCidr Invalid destination network segment.
RouteTableLimitExceeded Number of routing tables allowed to be created has been exceeded. Please contact customer service for more resources. For more information on VPC resource restrictions, refer to VPC Usage Restrictions.
RouteLimitExceeded The upper limit of number of routing table policies has been exceeded. Please contact customer service for more resources. For more information on VPC resource restrictions, refer to VPC Usage Restrictions.
RouteAlreadyExists The destination network segment already exists in the routing table policy. No conflict between destination network segments is allowed in the same routing table.
InvalidRouteNextType Invalid next hop type. For supported types, refer to the descriptions of input parameters.
InvalidRouteNextHub.NotFound The next hop address does not exist. Please verify that you have entered next hop address resource ID correctly.

5. Example

Input

  https://vpc.api.qcloud.com/v2/index.php?Action=CreateRouteTable
  &<Common request parameters>
  &vpcId=vpc-amhnnao5
  &routeTableName=tttt111
  &routeSet.0.destinationCidrBlock=121.0.23.51/16
  &routeSet.0.nextType=1
  &routeSet.0.nextHub=vpngw-dystbrkv

Output


{
    "code": 0,
    "message": "",
    "routeTableId": "gz_rtb_8755",
    "unRouteTableId": "rtb-rqndayhs",
    "routeTableSet": [
        {
            "destinationCidrBlock": "121.0.23.51\/16",
            "nextType": 1,
            "nextHub": "vpngw-dystbrkv"
        }
    ]
}