Creating an SNAT Rule
Function
This API is used to create an SNAT rule.
You can create an SNAT rule only when status of the NAT gateway is set to ACTIVE and admin_state_up of the NAT gateway administrator to True.
URI
POST /v2/{project_id}/snat_rules
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Specifies the project ID. |
Request
Table 2 describes the request parameters.
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
snat_rule |
Yes |
Object |
Specifies the SNAT rule object. For details, see Table 3. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
nat_gateway_id |
Yes |
String |
Specifies the NAT gateway ID. For details, see Querying NAT Gateways. |
network_id |
No |
String |
Specifies the network ID used by the SNAT rule. For details, seeQuerying Networks.Configure either network_id or cidr. |
cidr |
No |
String |
Specifies a CIDR block or a host IP address. This parameter and network_id are alternative. If the value of source_type is 0, the CIDR block must be a subset of the VPC subnet CIDR block. If the value of Source_type is 1, cidr must be a CIDR block of Direct Connect connection. |
source_type |
No |
Integer |
0: Either network_id or cidr can be specified in a VPC. 1: Only cidr can be specified over a Direct Connect connection. If no value is entered, the default value 0 (VPC) is used. |
floating_ip_id |
Yes |
String |
Specifies the EIP ID. Multiple EIP IDs must be separated using commas (,). The maximum length of the ID is 4096 bytes. The number of EIP IDs cannot exceed 20. |
description |
No |
String |
Provides supplementary information about the SNAT rule. You can enter up to 255 characters. |
Response
Table 4 lists response parameters.
Parameter |
Type |
Description |
---|---|---|
snat_rule |
Object |
Specifies the SNAT rule object. For details, see Table 5. |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Specifies the SNAT rule ID. |
tenant_id |
String |
Specifies the project ID. |
nat_gateway_id |
String |
Specifies the NAT gateway ID. |
network_id |
String |
Specifies the network ID used by the SNAT rule. |
cidr |
String |
Specifies a subset of the VPC subnet CIDR block or a CIDR block of Direct Connect connection. |
source_type |
Integer |
0: Either network_id or cidr can be specified in a VPC. 1: Only cidr can be specified over a Direct Connect connection. If no value is entered, the default value 0 (VPC) is used. |
floating_ip_id |
String |
|
description |
String |
Provides supplementary information about the SNAT rule. You can enter up to 255 characters. |
status |
String |
|
admin_state_up |
Boolean |
|
created_at |
String |
|
floating_ip_address |
String |
|
Examples
- Example request
- Configure parameter network_id in a VPC.
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" } }
- Configure parameter cidr in a VPC.
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" } }
- Configure parameter cidr over a Direct Connect connection.
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" } }
- Configure parameter network_id in a VPC.
- Example response
- Response to the request for specifying the network_id for a VPC
{ "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" } }
- Response to the request for specifying the CIDR block in a VPC
{ "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" } }
- Response to the request for specifying the CIDR block in a VPC
{ "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" } }
- Response to the request for specifying the network_id for a VPC
Status Codes
See Status Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.