Create DNAT rules
Updated at:2025-10-16
Create DNAT rules
Description
Create DNAT rules for the NAT gateway
Request structure
Plain Text
1POST /v{version}/nat/{natId}/dnatRule?clientToken={clientToken} HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: authorization string
4{
5 "ruleName":"test",
6 "publicIpAddress":"100.88.14.90",
7 "privateIpAddress":"192.168.1.1",
8 "protocol":"TCP",
9 "publicPort":1212,
10 "privatePort":1212
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 | API version number, current value is 1. |
| clientToken | String | Yes | Query | Idempotence token, which is an ASCII string with a length not exceeding 64 bits, see details in [ClientToken Idempotence Support](VPC/API Reference/General Description.md) |
| natId | String | Yes | URL parameter | NAT gateway ID |
| ruleName | String | No | RequestBody | Name, which supports uppercase and lowercase letters, numbers, and special characters such as-, , _, / and., starting with a letter, with a length of 1-65. |
| publicIpAddress | String | Yes | RequestBody | Public IP: EIP or IP from EIPGROUP associated with the dnatEips or bindEips of the NAT gateway |
| privateIpAddress | String | Yes | RequestBody | Internal IP address |
| protocol | String | Yes | RequestBody | Protocol, supporting TCP, UDP, all |
| publicPort | Integer | No | RequestBody | Public port (1-65535), valid for TCP/UDP protocols and unavailable to be specified simultaneously with port ranges |
| privatePort | Integer | No | RequestBody | Intranet port (1-65535), valid for TCP/UDP protocols and unavailable to be specified simultaneously with port ranges |
| publicPortRange | String | No | RequestBody | Public port range (80-90), valid for TCP/UDP protocols and unavailable to be specified simultaneously with a single port |
| privatePortRange | String | No | RequestBody | Intranet port range (80-90), valid for TCP/UDP protocols and unavailable to be specified simultaneously with a single port |
Response headers
No special headers are required beyond the standard ones.
Response parameters
| Parameter name | Types | Description |
|---|---|---|
| ruleId | String | ID of the created DNAT rule |
Request example
Plain Text
1POST /v1/nat/nat-brkztytqzbh0/dnatRule?clientToken=be31b98c-5e41-4838-9830-9be700de5a20 HTTP/1.1
2Host: bcc.bj.baidubce.com
3ContentType: application/json
4Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2018-07-05T04:17:29Z/3600/ host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
5{
6 "ruleName":"test",
7 "publicIpAddress":"100.88.14.90",
8 "privateIpAddress":"192.168.1.1",
9 "protocol":"TCP",
10 "publicPort":1212,
11 "privatePort":1212,
12}
Response example
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
3Date: Fri, 06 July 2018 07:06:06 GMT
4Content-Type: application/json;charset=UTF-8
5Server: BWS
6{
7 "ruleId": "rule-zrsaybxm7nrn"
8}
