Adds custom route entries to the route table of a vRouter.

Usage notes

  • CreateRouteEntries is an asynchronous operation. After you send a request, the system returns a request ID and runs the task in the background. You can call the DescribeRouteEntryList operation to query the status of a route entry:
    • If the route entry is in the Creating state, the route entry is being created.
    • If the route entry is in the Created state, the route entry is created.
  • You cannot repeatedly call the CreateRouteEntries operation to create the same route entry within the specified period of time.
When you call this operation to add custom route entries to the route table of a vRouter, take note of the following items:
  • A route table can contain up to 200 custom route entries.
  • The destination CIDR block (DstCidrBlock) of a custom route entry cannot be the same as or overlap with the CIDR block of a vSwitch in the virtual private cloud (VPC).
  • The destination CIDR block (DstCidrBlock) of a custom route entry cannot be 100.64.0.0/10 or its subnets.
  • The destination CIDR blocks (DstCidrBlock) of route entries in the same route table must be unique.
  • If you do not include the mask length when you specify the destination CIDR block (DstCidrBlock), the destination CIDR block is considered a host IP address whose mask length is 32 bits.
  • Multiple custom route entries can point to the same next hop (NextHop).
  • The next hop (NextHop) of a custom route entry must belong to the same VPC as the route table.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code for different SDKs.

Request parameter

Parameter Type Required Example Description
Action String Yes CreateRouteEntries

The operation that you want to perform. Set the value to CreateRouteEntries.

RegionId String Yes cn-hangzhou

The ID of the region where the route table is created.

You can call the DescribeRegions operation to query the most recent region list.

RouteEntries.N.DstCidrBlock String Yes 192.168.0.0/24

The destination CIDR block of the custom route entry. Both IPv4 and IPv6 CIDR blocks are supported. You can specify up to 50 destination CIDR blocks. Make sure that the destination CIDR block meets the following requirements:

  • The destination CIDR block is not 100.64.0.0/10 or a subset of 100.64.0.0/10.
  • The destination CIDR block of the custom route entry is different from the destination CIDR blocks of other route entries in the same route table.
RouteEntries.N.RouteTableId String Yes vtb-bp145q7glnuzd****

The ID of the route table to which you want to add the custom route entry. You can specify up to 50 route table IDs.

RouteEntries.N.IpVersion Integer No IPv4

The version of the IP protocol. You can specify up to 50 IP protocol versions. Valid values:

  • IPv4
  • IPv6
RouteEntries.N.NextHop String Yes i-j6c2fp57q8rr4jlu****

The ID of the next hop of the custom route entry. You can specify up to 50 next hop IDs.

RouteEntries.N.NextHopType String Yes RouterInterface

The type of next hop. You can specify up to 50 next hop types. Valid values:

  • Instance: an Elastic Compute Service (ECS) instance. This is the default value.
  • HaVip: a high-availability virtual IP address (HAVIP).
  • RouterInterface: a router interface.
  • NetworkInterface: an elastic network interface (ENI).
  • VpnGateway: a VPN gateway.
  • IPv6Gateway: an IPv6 gateway.
  • NatGateway: a NAT gateway.
  • Attachment: a transit router.
  • VpcPeer: a VPC peering connection.
RouteEntries.N.Name String No test

The name of the custom route entry that you want to add. You can specify up to 50 names.

The name must be 1 to 128 characters in length and cannot start with http:// or https://.

RouteEntries.N.Description String No test

The description of the custom route entry. You can specify up to 50 descriptions.

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

Response parameters

Parameter Type Example Description
SuccessCount Integer 2

The number of custom route entries that were successfully added.

FailedCount Integer 2

The number of custom route entries that failed to be added.

RequestId String 0ED8D006-F706-4D23-88ED-E11ED28DCAC0

The ID of the request.

FailedRouteEntries Array of FailedRouteEntries

The details about the custom route entry that failed to be added.

DstCidrBlock String 192.168.0.0/24

The destination CIDR block of the custom route entry that failed to be added.

NextHop String i-j6c2fp57q8rr4jlu****

The ID of the next hop of the custom route entry that failed to be added.

FailedCode String VPC_ROUTE_ENTRY_CIDR_BLOCK_DUPLICATE

The error code.

FailedMessage String Specified CIDR block is already exists, entry.cidrBlock=xxxx

The error message.

RouteEntryIds Array of String rte-sn6vjkioxte1gz83z****

The ID of the custom route entry that was successfully added.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateRouteEntries
&RegionId=cn-hangzhou
&RouteEntries=[{"DstCidrBlock":"192.168.0.0/24","RouteTableId":"vtb-bp145q7glnuzd****","NextHop":"i-j6c2fp57q8rr4jlu****","NextHopType":"RouterInterface","Name":"test","Description":"test"}]
Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateRouteEntriesResponse>
    <SuccessCount>2</SuccessCount>
    <FailedCount>2</FailedCount>
    <RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
    <FailedRouteEntries>
        <DstCidrBlock>192.168.0.0/24</DstCidrBlock>
        <NextHop>i-j6c2fp57q8rr4jlu****</NextHop>
        <FailedCode>VPC_ROUTE_ENTRY_CIDR_BLOCK_DUPLICATE</FailedCode>
        <FailedMessage>Specified CIDR block is already exists, entry.cidrBlock=xxxx</FailedMessage>
    </FailedRouteEntries>
    <RouteEntryIds>rte-sn6vjkioxte1gz83z****</RouteEntryIds>
</CreateRouteEntriesResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "SuccessCount" : 2,
  "FailedCount" : 2,
  "RequestId" : "0ED8D006-F706-4D23-88ED-E11ED28DCAC0",
  "FailedRouteEntries" : [ {
    "DstCidrBlock" : "192.168.0.0/24",
    "NextHop" : "i-j6c2fp57q8rr4jlu****",
    "FailedCode" : "VPC_ROUTE_ENTRY_CIDR_BLOCK_DUPLICATE",
    "FailedMessage" : "Specified CIDR block is already exists, entry.cidrBlock=xxxx"
  } ],
  "RouteEntryIds" : [ "rte-sn6vjkioxte1gz83z****" ]
}

Error codes

HttpCode Error code Error message Description
400 DryRunOperation Request validation has been passed with DryRun flag set. The error message returned because the request passed the dry run.

For a list of error codes, visit the API Error Center.