Create route rules
Updated at:2025-10-16
Description
When creating route table rules, note the following points:
- When selecting a custom source network segment, the custom segment must fall within the range of existing subnets, excluding 0.0.0.0/0;
- The destination segment must not overlap with the current VPC CIDR (except when either is 0.0.0.0/0);
- The source and destination network segments of a new route entry must not be identical to those of any existing entries in the route table;
Request structure
Plain Text
1 POST /v{version}/route/rule?clientToken={clientToken} HTTP/1.1
2 Host: bcc.bj.baidubce.com
3 Authorization: authorization string
4 {
5 "routeTableId":{routeTableId},
6 "sourceAddress": {sourceAddress},
7 "destinationAddress": {destinationAddress},
8 "nexthopId": {nexthopId},
9 "nexthopType": {nexthopType},
10 "description": {description}
11 }
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Whether required | Parameter location | Description |
|---|---|---|---|---|
| version | String | Yes | URL parameter | For API version No., the current value is 1 |
| clientToken | String | No | Query | Idempotence Token, which is an ASCII string with a length not exceeding 64 bits, see details in [ClientToken Idempotence](VPC/API Reference/General Description.md#Idempotence). |
| routeTableId | String | Yes | Request Body parameters | Route table ID |
| sourceAddress | String | Yes | Request Body parameters | Source network segment (can be 0.0.0.0/0 for all segments, existing VPC subnet segments, or subnet private segments) |
| destinationAddress | String | Yes | Request Body parameters | Destination segment |
| nexthopId | String | No | Request Body parameters | Next hop ID, mandatory for the creation of single-line routing |
| nexthopType | String | No | Request Body parameters | Routing type, mandatory for single-line routes; the Bcc type is "custom"; the VPN type is "vpn"; the NAT type is "nat"; and the dedicated gateway type is "dcGateway" |
| nextHopList | List<[NextHop](VPC/API Reference/Appendix.md#NextHop)> | No | Request Body parameters | Next hop information for multi-line routing, mandatory for the creation of multi-line routing |
| description | String | No | Request Body parameters | Description of the route table rule, no more than 200 characters |
Response headers
No special headers are required beyond the standard ones.
Response parameters
| Parameter name | Types | Description |
|---|---|---|
| routeRuleId | String | ID of the single-line routing rule, which is returned when creating a single-line route |
| routeRuleIds | List<String> | ID of the multi-line routing rule, which is returned when creating a multi-line route (active/standby, load balancer) |
Request example
Plain Text
1 POST /v1/route/rule?clientToken=3fcf57c1-73c7-42c9-8075-6dda96c06f6b HTTP/1.1
2 Host: bcc.bj.baidubce.com
3 Content-Type: application/json;charset=UTF-8
4 Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2017-03-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
5{
6 "routeTableId":"rt-q1zg3i8mx8p6",
7 "sourceAddress": "192.168.0.0/20",
8 "destinationAddress": "0.0.0.0/0",
9 "nexthopId": "nat-bdidwhwfwc6p",
10 "nexthopType": "nat",
11 "description": "this is a route rule"
12}
Response example
Plain Text
1 HTTP/1.1 200 OK
2 x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
3 Date: Thu, 16 Mar 2017 06:29:48 GMT
4 Content-Type: application/json;charset=UTF-8
5 Server: BWS
6{
7 "routeRuleId": "rr-dup3cxpebi5e"
8}
