Adds a custom route entry to the route table of a vRouter or a virtual border router (VBR).

Usage notes

  • CreateRouteEntry is an asynchronous operation. After a request is sent, the system returns a request ID and runs the task in the background. You can call the DescribeRouteEntryList operation to query the status of the task:
    • If a route is in the Creating state, the route is being added.
    • If a route is in the Created state, the route is added.
  • You cannot repeatedly call CreateRouteEntry within a specific period of time.
When you call this operation to add a custom route entry to the route table of a vRouter, take note of the following items:
Note When you add a route entry from a prefix list, the quota usage is calculated by adding the number of existing route entries and the maximum number of route entries of the prefix list.
  • A route table can contain up to 200 custom route entries.
  • The destination CIDR block (DestinationCidrBlock) of a custom route entry cannot be the same as or be a subset of the CIDR block of a vSwitch in the virtual private cloud (VPC). The destination CIDR block can contain the CIDR block of a vSwitch.
  • The destination CIDR block (DestinationCidrBlock) of a custom route entry cannot be 100.64.0.0/10 or a subset of it.
  • The destination CIDR blocks (DestinationCidrBlock) 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 (DestinationCidrBlock), 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 (NextHopId).
  • The next hop (NextHopId) of a custom route entry must belong to the same VPC as the route table.
  • Equal-cost multi-path (ECMP) routing can be configured by specifying NextHopList.
    • When you add non-ECMP route entries, you must specify DestinationCidrBlock, NextHopType, and NextHopId, and you must not specify NextHopList.
    • When you add route entries for ECMP routing, you must specify DestinationCidrBlock and NextHopList, and you must not specify NextHopType or NextHopId.
When you call this operation to add a custom route entry to the route table of a VBR, take note of the following limits:
  • A route table can contain up to 200 custom route entries.
  • NextHopList is not supported.
  • The destination CIDR block (DestinationCidrBlock) of a custom route entry cannot be 100.64.0.0/10 or a subset of it.
  • The destination CIDR blocks (DestinationCidrBlock) 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 (DestinationCidrBlock), 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 (NextHopId).
  • The next hop (NextHopId) of a custom route entry must be a router interface associated with the VBR.
  • You can add route entries only when the VBR is in the Active state, and the Express Connect circuit associated with the VBR is in the Enabled state and is not locked due to overdue payments.
  • Only non-ECMP route entries are supported. When you add non-ECMP route entries, you must specify DestinationCidrBlock, NextHopType, and NextHopId, and you cannot specify NextHopList.

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 of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateRouteEntry

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

RegionId String No cn-hangzhou

The region ID of the route table.

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

RouteTableId String Yes vtb-bp145q7glnuzd****

The ID of the route table to which you want to add a custom route entry.

DestinationCidrBlock String Yes 192.168.0.0/24

The destination CIDR block of the custom route entry. Both IPv4 and IPv6 CIDR blocks are supported. 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.
NextHopId String No i-j6c2fp57q8rr4jlu****

The ID of the next hop of the custom route entry.

ClientToken String No 02fb3da4-130e-11e9-8e44-001****

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters.

Note If you do not specify this parameter, the system automatically uses the request ID as the client token. The request ID may be different for each request.
RouteEntryName String No test

The name of the custom route entry that you want to add.

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

Description String No test

The description of the custom route entry.

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

NextHopType String No RouterInterface

The type of next hop of the custom route entry. 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.
NextHopList.N.NextHopId String No ri-2zeo3xzyf3cd8r4****

The ID of the next hop of the ECMP route.

NextHopList.N.Weight Integer No 10

The weight of the next hop of the ECMP route entry.

NextHopList.N.NextHopType String No RouterInterface

The type of next hop of the ECMP route entry. Set the value to RouterInterface.

Response parameters

Parameter Type Example Description
RouteEntryId String rte-sn6vjkioxte1gz83z****

The ID of the custom route entry.

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

The request ID.

Description

Sample requests

http(s)://[Endpoint]/?Action=CreateRouteEntry
&RegionId=cn-hangzhou
&RouteTableId=vtb-bp145q7glnuzd****
&DestinationCidrBlock=192.168.0.0/24
&NextHopId=i-j6c2fp57q8rr4jlu****
&ClientToken=02fb3da4-130e-11e9-8e44-001****
&RouteEntryName=test
&Description=test
&NextHopType=RouterInterface
&NextHopList=[{"NextHopId":"ri-2zeo3xzyf3cd8r4****","Weight":10,"NextHopType":"RouterInterface"}]
&Common request parameters

Sample success responses

XML format

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

<CreateRouteEntryResponse>
    <RouteEntryId>rte-sn6vjkioxte1gz83z****</RouteEntryId>
    <RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
</CreateRouteEntryResponse>

JSON format

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

{
  "RouteEntryId" : "rte-sn6vjkioxte1gz83z****",
  "RequestId" : "0ED8D006-F706-4D23-88ED-E11ED28DCAC0"
}

Error codes

HttpCode Error code Error message Description
400 IllegalParam.CidrBlock The specified CidrBlock is illegal. CidrBlock is set to an invalid value.
400 QuotaExceeded Route entry quota exceeded in this route table. The number of route entries in the route table has reached the upper limit.
400 MissingParameter Miss mandatory parameter. One or more required parameters are not set. Check whether you have set all required parameters before you call this operation.
400 InvalidCidrBlock.Malformed Specified CIDR block is not valid. The format of the specified CIDR block is invalid.
400 InvalidCIDRBlock.Duplicate Specified CIDR block is already exists. The specified CIDR block already exists in the route table.
400 IncorrectVpcStatus Current VPC status does not support this operation. This operation cannot be performed when the VPC is in the current state.
400 IncorrectInstanceStatus Current instance status does not support this operation. This operation cannot be performed while the instance is in the current state.
400 IncorrectRouteEntryStatus Some route entry status blocked this operation. One or more route entries in the current route table are in the Pending or Modifying state.
400 IncorrectVSwitchStatus The current virtual switch status does not support this operation. The vSwitch is in the Pending state and cannot be deleted.
400 InvalidCidrBlock Specified CIDR block is not valid. The error message returned for one of the following reasons: 1. You are unauthorized to use the 10.0.0.0/8 CIDR block. Check whether your account is included in the whitelist to use the CIDR block. 2. The destination CIDR block of the added custom route entry cannot be a subset of the CIDR blocks of the vSwitches in the VPC. 3. The CIDR block cannot be 100.64.0.0/10.
400 InvalidNextHopType Specified parameter "NextHopType" is not valid The specified next hop type is invalid.
400 InvalidNextHop.NotFound Specified next hop does not exist. The specified next hop does not exist.
400 InvalidVRouter.NotFound vRouter not exists. The specified vRouter does not exist. Check whether the specified vRouter is valid.
400 InvalidVPC.NotFound vpc not exists. The specified VPC does not exist. Check whether the specified VPC is valid.
400 InvalidNexthopTypeAndList.BothNull both nexthopType and nextHopList are null. NextHopType and NextHopList are not specified.
400 InvalidNexthopTypeAndList.BothNotNull both nexthopType and nextHopList are not null. You cannot leave both NextHopType and the NextHopList empty.
400 InvalidRouterInterface invalid router interface. The specified router interface does not exist.
400 InvalidOppositeRouterType nexthop list cannot only contain router interface whose opposite router interface is on vbr. The specified next hop is invalid. The peer router of the router interface that you specify as the next hop must be a VBR.
400 InvalidNexthopListSize nexthop size is illegal. Must be between 2 and 4. You must specify two to four router interfaces as next hops.
400 InvalidEntryRuleQuota.NotFound Route entry quota rule not exists. The quota rules of route entries do not exist.
400 Forbidden.CheckEntryRuleQuota Route entry quota rule check error. An error occurred when the system was checking the quota of route entries.
400 InvalidVBRStatus invalid virtual border router status. The VBR is in an invalid state.
400 InvalidPhysicalConnectionBusinessStatus invalid physical connection business status. The Express Connect circuit is in an invalid state.
400 IncorrectHaVipStatus This operation is denied because satus of the specified HaVip is neither Available nor InUse. You cannot perform the operation when the specified HAVIP is in the Available or InUse state.
400 CountLimitExceed.HaVipRouteEntry There can be 5 route entry to HaVip at most in one route table. The number of route entries that point to the HAVIP has reached the upper limit.
400 InvalidRouteEntry.Duplicate The route entry already exist. The specified route entry already exists.
400 IncorrectRouteEntryStatus Specified routeEntry status error. One or more route entries in the current route table are in the Pending or Modifying state.
400 IncorrectRouteEntryStatus VBR has NotStable route entry. One or more route entries in the current VBR are in the Pending or Modifying state.
400 InvalidParam The Ecmp routerEntry with router interfaces local vgw vip not match. The route entry does not match the gateway IP address of the router interface.
400 INVALID_WEIGHT_PARAM Specified value of weight invalid The specified weight is invalid.
400 FORBIDDEN_USE_VPC_AS_INTERNET_GATEWAY The Specified CIDR must be in vpc CIDR. The specified CIDR block must be a subset of the VPC CIDR block.
400 INVALID_VPC_ID The Specified VpcId not match. The specified VPC does not exist. Check whether the specified VPC ID is valid.
400 InvalidRouteEntrySize The Specified routerEntry size not legal. You must specify two to four router interfaces as next hops if you want to configure ECMP routing.
400 TaskConflict The operation is too frequent, please wait a moment and try again. Your requests are too frequent. Try again later.
400 InvalidRouteEntry Specified routeEntry not exist. The specified route entry does not exist.
400 RouteConflict.AlreadyExist Route conflict exists in routing table. Route conflicts exist in the route table.
400 InvalidRouteEntryName.Malformed Specified RouteEntry name is not valid. The name of the route entry is invalid.
400 InvalidNexthop.DirectEni The direct Eni cannot be nexthop. An ENI in cut-through mode cannot be specified as a next hop.
400 QuotaExceeded.VpnRouteEntry Vpn route entry quota exceeded. The system failed to create the route entry. Check whether the number of route entries in the VPN gateway route table reaches the upper limit.
400 InvalidAttachment.NotFound The attachment is not found. The specified transit router does not exist.
400 OperationFailed.ActiveNetworkInterfaceNotFound No active network interface is found on the attachment. No ENI is available on the specified transit router.
400 InvalidNetworkInterface.NotFound The network interface is not found on the attachment. No ENI is associated with the specified transit router.
400 OperationFailed.QueryAttachmentInfo Failed to query attachment information. The system fails to query the transit router.
400 IllegalParam.AttachmentId The attachment is invalid. The specified transit router is invalid.
400 OperationFailed.NotSupportIPV6 The specified next hop does not support IPv6. The specified next hop does not support IPv6.
400 IncorrectStatus.Ipv6Address The IPv6 address of the specified next hop is being assigned or deleted. An IPv6 address is being assigned to or removed from the next hop.
400 OperationUnsupported.Ipv6EntryOnPrimaryNetworkInterface You cannot create IPv6 route entries on a primary network interface. You cannot create an IPv6 route entry whose next hop is a primary ENI.
400 OperationUnsupported.SpecifyIpOnIpv6Entry You cannot specify the private IP address when you create IPv6 route entries. You cannot specify a private IPv6 address as the destination CIDR block.
400 OperationUnsupported.MutipleIpv6Address You cannot specify a next hop that has bound multiple IPv6 addresses. You cannot specify a next hop that is assigned multiple IPv6 addresses.
400 OperationDenied.Ipv6EntryOnCustomTable You cannot create any IPv6 route entry on a custom route table. You cannot add an IPv6 route entry to a custom route table.
400 OperationDenied.CloudBoxVbrEntryAllowedInCustomRouteTable The operation is not allowed because only the custom routing table can add a routing entry with the next hop pointing to the cloud box type VBR. You can add a route entry to a custom route table only if the next hop of the route entry points to a VBR connected to a cloud box.
400 OperationDenied.RouteTableAssociateNotCloudBoxVSwitch The operation is not allowed because of the routing table is bound to a non-cloud box type vswitch, and routing entries pointing to the cloud box VBR cannot be added. The vSwitch with which the route table is associated is not connected to a CloudBox instance. Therefore, you cannot add a route entry that points to a VBR connected to a CloudBox instance.
400 OperationDenied.VbrMisMatchCloudBox The operation is not allowed because the routing table is bound to a cloud box vswitch, and routing entries pointing to other cloud box VBRs cannot be added. The VBR and the vSwitch that is associated with the route table are connected to different CloudBox instances.
400 OperationDenied.VbrIdle The operation is not allowed because the next hop of the added routing entry is a VBR type RI at the opposite end, which cannot be in an idle state. The router interface that you specify as the next hop is in the Idle state. If the peer router of the next hop router interface is a VBR, the next hop router interface must not be in the Idle state.
400 OperationDenied.RouterInterfaceToDifferentVpc The operation is not allowed because the router interface is connected to different VPCs. The router interfaces that you specify as next hops when you configure ECMP routing do not belong to the same VPC.
400 OperationDenied.RouterInterfaceFromDifferentZones The operation is not allowed because the router interface resides in different zones. The router interface belongs to a different zone.
400 OperationFailed.PconnTrafficNotEnable The operation is failed because of PconnTrafficNotEnable. Outbound data transfer billing is disabled.
400 ResourceNotFound.VpcPeer The specified resource of %s is not found. The peer VPC cannot be found.
400 OperationDenied.RouteTableTypeNotPermitted The operation is not allowed because the type of route table is not permitted. You cannot add route entries to route tables of the specified type.
400 OperationDenied.GatewayRouteTableNotPermitted The operation is not allowed to create a route pointing to this nextHop type on gateway route table. The gateway route table does not support route entries that point to the specified instance type.
400 UnsupportedFeature.VpcPeerIpv6 IPv6 route entries for VPC peering connections cannot be created in this region. The peer of the router interface is a VPC and you cannot create a route whose next hop type is an IPv6 address in this region.
400 OperationDenied.VpcIpv6NotEnabled IPv6 has not been enabled for the VPC. The VPC does not support IPv6 and the operation is denied.
400 IncorrectStatus.Ipv4Gateway The status of Ipv4Gateway is incorrect. The IPv4 gateway is unstable.
400 ResourceNotFound.PrefixList The specified resource of prefixList is not found. The prefix list does not exist.
400 UnsupportedFeature.CreatePrefixListEcmpRouteEntry The feature of creating ecmp route entry with prefixList is not supported. You cannot create ECMP routes by using a prefix list.
400 OperationDenied.RouterInterfaceIpv6NotEnabled Routerinterface does not support IPv6. The operation failed because the router interface does not support IPv6.
400 OperationDenied.NextHopTypeNotPermitted The operation is not allowed because the nextHop type is invalid. You are not allowed to create a route whose next hop is of this type.
403 IncorrectInstanceStatus The current status of the resource does not support this operation. The specified resource is in a state that does not support the operation.
404 InvalidInstanId.NotFound Specified instance does not exist. The specified instance does not exist. Check whether the instance ID is valid.
404 InvalidNextHopId.NotFound Specified next hop does not exist. The specified next hop does not exist.
404 InvalidRouteTableId.NotFound Specified route table does not exist. The specified route table does not exist.
404 InvalidHaVipId.NotFound The specified HaVip does not exist in the specified VPC. The specified HAVIP does not exist in the VPC.
500 InternalError The request processing has failed due to some unknown error, exception or failure. An internal error has occurred.

For a list of error codes, see Service error codes.