创建SNAT规则
功能介绍
创建SNAT规则。
 
 
   创建规则时,要求网关状态status = "ACTIVE",要求网关管理员状态admin_state_up = True。
URI
POST /v2/{project_id}/snat_rules
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| project_id | 是 | String | 项目ID。 | 
请求消息
请求参数如表2所示。
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| nat_gateway_id | 是 | String | NAT网关的id。请参考查询NAT网关列表 | 
| network_id | 否 | String | 规则使用的网络id。与cidr参数二选一。 | 
| cidr | 否 | String | 可以是网段或者主机格式,与network_id参数二选一。 Source_type=0时,cidr必须是vpc子网网段的子集(不能相等); Source_type=1时,cidr必须指定专线侧网段。 | 
| source_type | 否 | Integer | 0:VPC侧,可以指定network_id或者cidr。 1:专线侧,只能指定cidr。 不输入默认为0(VPC)。 | 
| floating_ip_id | 是 | String(4096) | 功能说明:弹性公网IP的id,多个弹性公网IP的id使用逗号分隔。 取值范围:最大长度4096字节。 约束:弹性公网IP的id个数不能超过20个。 | 
| description | 否 | String(255) | SNAT规则的描述。 | 
响应消息
响应参数如表4所示。
| 参数 | 参数类型 | 描述 | 
|---|---|---|
| id | String | SNAT规则的id。 | 
| tenant_id | String | 项目ID。 | 
| nat_gateway_id | String | NAT网关的id。 | 
| network_id | String | 规则使用的网络id。 | 
| cidr | String | cidr,vpc子网网段的子集或专线侧网段。 | 
| source_type | Integer | 0:VPC侧,可以指定network_id或者cidr。 1:专线侧,只能指定cidr。 不输入默认为0(VPC)。 | 
| floating_ip_id | String(4096) | 
 | 
| description | String(255) | SNAT规则的描述。 | 
| status | String | 
 | 
| admin_state_up | Boolean | 
 | 
| created_at | String | 
 | 
| floating_ip_address | String(1024) | 
 | 
| freezed_ip_address | String(1024) | 
 | 
示例
- 请求样例
    - VPC 侧指定network_id
      POST https://{Endpoint}/v2/d199ba7e0ba64899b2e81518104b1526/snat_rules { "snat_rule": { "nat_gateway_id": "a78fb3eb-1654-4710-8742-3fc49d5f04f8", "network_id": "eaad9cd6-2372-4be1-9535-9bd37210ae7b", "source_type":0, "floating_ip_id": "bdc10a4c-d81a-41ec-adf7-de857f7c812a", "description": "my snat rule 01" } }
 - VPC侧指定CIDR
      POST /v2/d199ba7e0ba64899b2e81518104b1526/snat_rules { "snat_rule": { "nat_gateway_id": "a78fb3eb-1654-4710-8742-3fc49d5f04f8", "cidr": "192.168.1.10/32", "source_type":0, "floating_ip_id": "bdc10a4c-d81a-41ec-adf7-de857f7c812a", "description": "my snat rule 01" } }
 - 专线侧 指定CIDR
      POST https://{Endpoint}/v2/d199ba7e0ba64899b2e81518104b1526/snat_rules { "snat_rule": { "nat_gateway_id": "a78fb3eb-1654-4710-8742-3fc49d5f04f8", "cidr": "172.30.0.0/24", "source_type":1, "floating_ip_id": "bdc10a4c-d81a-41ec-adf7-de857f7c812a", "description": "my snat rule 01" } }
 
- VPC 侧指定network_id
      
- 响应样例
    - VPC 侧指定network_id的响应
      { "snat_rule": { "floating_ip_id": "bdc10a4c-d81a-41ec-adf7-de857f7c812a", "status": "PENDING_CREATE", "nat_gateway_id": "a78fb3eb-1654-4710-8742-3fc49d5f04f8", "admin_state_up": true, "network_id": "eaad9cd6-2372-4be1-9535-9bd37210ae7b", "description": "", "source_type":0, "tenant_id": "27e25061336f4af590faeabeb7fcd9a3", "created_at": "2017-11-18 07:54:21.665430", "id": "5b95c675-69c2-4656-ba06-58ff72e1d338", "floating_ip_address": "5.21.11.226" } }
- VPC 侧指定CIDR的响应
      { "snat_rule": { "floating_ip_id": "bdc10a4c-d81a-41ec-adf7-de857f7c812a", "status": "PENDING_CREATE", "nat_gateway_id": "a78fb3eb-1654-4710-8742-3fc49d5f04f8", "admin_state_up": true, "cidr": "192.168.1.10/32", "description": "", "source_type":0, "tenant_id": "27e25061336f4af590faeabeb7fcd9a3", "created_at": "2017-11-18 07:54:21.665430", "id": "5b95c675-69c2-4656-ba06-58ff72e1d338", "floating_ip_address": "5.21.11.226" } }
- 专线侧指定CIDR的响应
      { "snat_rule": { "floating_ip_id": "bdc10a4c-d81a-41ec-adf7-de857f7c812a", "status": "PENDING_CREATE", "nat_gateway_id": "a78fb3eb-1654-4710-8742-3fc49d5f04f8", "admin_state_up": true, "cidr": "172.30.0.0/24", "description": "", "source_type":1, "tenant_id": "27e25061336f4af590faeabeb7fcd9a3", "created_at": "2017-11-18 07:54:21.665430", "id": "5b95c675-69c2-4656-ba06-58ff72e1d338", "floating_ip_address": "5.21.11.226" } }
 
- VPC 侧指定network_id的响应
      
状态码
请参考状态码。
 
    