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

Descriptions

When you call this operation to add a custom route entry to a route table of a vRouter, take note of the following limits:
  • A route table can contain up to 200 custom route entries.
  • The destination CIDR block (DestinationCidrBlock) of a custom route entry and the CIDR block of a vSwitch in a virtual private cloud (VPC) cannot be the same or be a subset of each other.
  • 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 cannot be the same.
  • 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 be destined for 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 the NextHopList parameter.
    • When you add regular 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.
  • The NextHopList parameter 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 cannot be the same.
  • 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 be destined for 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 unlocked.
  • You cannot add route entries for ECMP routing. When you add regular route entries, you must specify DestinationCidrBlock, NextHopType, and NextHopId, and you must not 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.

DestinationCidrBlock String Yes 192.168.0.1/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.
RouteTableId String Yes vtb-bp145q7glnuzd****

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

RegionId String Yes cn-hangzhou

The ID of the region to which the route table belongs. You can call the DescribeRegions operation to query the most recent region list.

NextHopId String No i-j6c2fp57q8rr4jlu****

The ID of the next hop.

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

The client token that is used to ensure the idempotency of the request. You can use the client to generate the value, but you must make sure that it is unique among different requests. ClientToken can contain only ASCII characters. It cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

RouteEntryName String No test

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

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

Description String No test

The description of the custom route entry.

NextHopType String No RouterInterface

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

The ID of the next hop for ECMP routing.

NextHopList.N.Weight Integer No 10

The weight of the next hop for ECMP routing.

NextHopList.N.NextHopType String No RouterInterface

The type of next hop for ECMP routing. Set the value to RouterInterface (router interface).

Response parameters

Parameter Type Example Description
RequestId String 0ED8D006-F706-4D23-88ED-E11ED28DCAC0

The ID of the request.

RouteEntryId String rte-sn6vjkioxte1gz83z****

The ID of the custom route entry.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateRouteEntry
&DestinationCidrBlock=192.168.0.1/24
&RouteTableId=vtb-bp145q7glnuzd****
&<Common request parameters>

Sample success responses

XML format

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

JSON format

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

Error codes

HttpCode Error code Error message Description
400 MissingParameter Miss mandatory parameter. The error message returned because the required parameters are not specified. Check whether you have set all the required parameters before you call this operation.
400 InvalidCidrBlock.Malformed Specified CIDR block is not valid. The error message returned because the format of the specified CIDR block is invalid.
400 InvalidCIDRBlock.Duplicate Specified CIDR block is already exists. The error message returned because the specified CIDR block already exists in the route table.
400 IncorrectVpcStatus Current VPC status does not support this operation. The error message returned because the status of the VPC does not support this operation.
400 IncorrectInstanceStatus Current instance status does not support this operation. The error message returned because this operation cannot be performed while the instance is in the current state.
400 QuotaExceeded Route entry quota exceeded in this route table. The error message returned because the number of route entries in the route table has reached the upper limit.
400 IncorrectRouteEntryStatus Some route entry status blocked this operation. The error message returned because one or more route entries in the current route table are in the Pending or Modifying state.
400 InvalidCidrBlock Specified CIDR block is not valid. The error message returned because 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 error message returned because the specified next hop type is invalid.
400 InvalidNextHop.NotFound Specified next hop does not exist. The error message returned because the IP address of the specified next hop does not exist.
400 InvalidVRouter.NotFound vRouter not exists. The error message returned because the specified vRouter does not exist. Check whether the specified vRouter is valid.
400 InvalidVPC.NotFound vpc not exists. The error message returned because the specified VPC does not exist. Check whether the specified VPC is valid.
400 InvalidNexthopTypeAndList.BothNull both nexthopType and nextHopList are null. The error message returned because the NextHopType and NextHopList parameters are not specified.
400 InvalidNexthopTypeAndList.BothNotNull both nexthopType and nextHopList are not null. The error message returned because you cannot leave both the NextHopType and NextHopList parameters empty.
400 InvalidRouterInterface invalid router interface. The error message returned because the specified router interface does not exist.
400 InvalidOppositeRouterType nexthop list cannot only contain router interface whose opposite router interface is on vbr. The error message returned because 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. The error message returned because you must specify two to four router interfaces as next hops.
400 InvalidEntryRuleQuota.NotFound Route entry quota rule not exists. The error message returned because the number of route entries that you create has reached the upper limit.
400 Forbidden.CheckEntryRuleQuota Route entry quota rule check error. The error message returned because an error occurs when the system checks the quota of route entries.
400 InvalidVBRStatus invalid virtual border router status. The error message returned because the VBR is in a state that does not support the operation.
400 InvalidPhysicalConnectionBusinessStatus invalid physical connection business status. The error message returned because the Express Connect circuit is in a state that does not support the operation.
400 IncorrectHaVipStatus This operation is denied because satus of the specified HaVip is neither Available nor InUse. The error message returned because 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 error message returned because the number of route entries that point to the HAVIP reaches the upper limit.
400 InvalidRouteEntry.Duplicate The route entry already exist. The error message returned because the specified route entry already exists.
400 IncorrectRouteEntryStatus Specified routeEntry status error. The error message returned because one or more route entries in the current route table are in the Pending or Modifying state.
400 IncorrectRouteEntryStatus VBR has NotStable route entry. The error message returned because 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 error message returned because the route entry does not match the gateway IP address of the router interface.
400 INVALID_WEIGHT_PARAM Specified value of weight invalid The error message returned because the specified weight is invalid.
400 FORBIDDEN_USE_VPC_AS_INTERNET_GATEWAY The Specified CIDR must be in vpc CIDR. The error message returned because the specified CIDR block must be a subset of the VPC CIDR block.
400 INVALID_VPC_ID The Specified VpcId not match. The error message returned because the specified VPC does not exist. Check whether the specified VPC is valid.
400 InvalidRouteEntrySize The Specified routerEntry size not legal. The error message returned because you must specify two to four router interfaces as next hops if you want to configure ECMP routing.
400 InvalidRouteEntry Specified routeEntry not exist. The error message returned because the specified route entry does not exist.
400 InvalidAttachment.NotFound The attachment is not found. The error message returned because the specified transit router does not exist.
400 OperationFailed.ActiveNetworkInterfaceNotFound No active network interface is found on the attachment. The error message returned because no ENI is available on the specified transit router.
400 InvalidNetworkInterface.NotFound The network interface is not found on the attachment. The error message returned because no ENI is associated with the specified transit router.
400 OperationFailed.QueryAttachmentInfo Failed to query attachment information. The error message returned because the system fails to query the transit router.
400 IllegalParam.AttachmentId The attachment is invalid. The error message returned because the specified transit router is invalid.
400 OperationFailed.NotSupportIPV6 The specified next hop does not support IPv6. The error message returned because the specified next hop does not support IPv6.
400 IncorrectStatus.Ipv6Address The IPv6 address of the specified next hop is being assigned or deleted. The error message returned because 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. The error message returned because 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. The error message returned because 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. The error message returned because 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. The error message returned because 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. The error message returned because 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 error message returned because the vSwitch with which the route table is associated is not connected to a cloud box. Therefore, you cannot add a route entry that points to a VBR connected to a cloud box.
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 error message returned because the VBR and the vSwitch that is associated with the route table are connected to different cloud boxes.
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 error message returned because 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 error message returned because 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 error message returned because the route interface belongs to a different zone.
400 OperationFailed.PconnTrafficNotEnable The operation is failed because of PconnTrafficNotEnable. The error message returned because outbound traffic billing is disabled.
403 IncorrectInstanceStatus The current status of the resource does not support this operation. The error message returned because the specified resource is in a state that does not support the operation.
404 InvalidInstanId.NotFound Specified instance does not exist. The error message returned because the specified instance does not exist. Check whether the ID of the instance is valid.
404 InvalidNextHopId.NotFound Specified next hop does not exist. The error message returned because the specified next hop does not exist.
404 InvalidRouteTableId.NotFound Specified route table does not exist. The error message returned because the specified route table does not exist.
404 InvalidHaVipId.NotFound The specified HaVip does not exist in the specified VPC. The error message returned because the specified HAVIP does not exist in the VPC.

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