Creates an SNAT entry in an SNAT table.
Operation description
This operation adds an SNAT entry to an enhanced Internet NAT gateway or a VPC NAT gateway. The term NAT gateway in this document refers to both types of NAT gateways.
Note the following when you call this operation to add an SNAT entry:
-
CreateSnatEntry is an asynchronous operation. After you make a request, the system returns an SNAT entry ID, but the SNAT entry is not immediately added. The system continues to process the request in the background. You can call DescribeSnatTableEntries to query the status of the SNAT entry:
-
If the SNAT entry is in the Pending state, the SNAT entry is being added. In this state, you can only perform query operations.
-
If the SNAT entry is in the Available state, the SNAT entry is added.
-
-
The vSwitch and ECS instance specified in the SNAT entry must belong to the VPC to which the NAT gateway belongs.
-
Each vSwitch and ECS instance can belong to only one SNAT entry.
-
If a high-availability virtual IP address (HaVip) exists in the vSwitch, you cannot add an SNAT entry.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
vpc:CreateSnatEntry |
create |
*SnatEntry
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID of the NAT gateway. You can call the DescribeRegions operation to query region IDs. Valid values:
|
cn-hangzhou |
| SnatTableId |
string |
Yes |
The ID of the SNAT table. |
stb-bp190wu8io1vgev**** |
| SourceVSwitchId |
string |
No |
The ID of the vSwitch.
Note
You must specify either the SourceCIDR parameter or the SourceVSwitchId parameter. |
vsw-bp1nhx2s9ui5o**** |
| SourceCIDR |
string |
No |
The CIDR block of the VPC, vSwitch, or ECS instance. You can also specify any CIDR block. SNAT entries support the following granularities:
Note
You must specify either the SourceCIDR parameter or the SourceVSwitchId parameter. |
10.1.1.0/24 |
| SnatIp |
string |
No |
When you add an SNAT entry to an Internet NAT gateway:
Note
If you specify multiple EIPs to configure an SNAT IPAM pool, service connections are allocated to the EIPs through a hash algorithm. Because service traffic of each connection varies, service traffic of the EIPs may be uneven. To prevent service interruptions caused by the bandwidth limit of a single EIP, add all EIPs to the same Internet Shared Bandwidth. When you add an SNAT entry to a VPC NAT gateway:
|
47.98.XX.XX |
| SnatEntryName |
string |
No |
The name of the SNAT entry. The name must be 2 to 128 characters in length, and must start with a letter or Chinese character. It cannot start with |
SnatEntry-1 |
| ClientToken |
string |
No |
The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that the value is unique among different requests. The Note
If you do not specify this parameter, the system automatically uses the RequestId of the API request as the ClientToken. The RequestId of each API request may be different. |
02fb3da4-130e-11e9-8e44**** |
| EipAffinity |
integer |
No |
Specifies whether to enable EIP affinity. Valid values:
Note
After EIP affinity is enabled, if the SNAT entry is associated with multiple EIPs or NAT IP addresses, the same EIP or NAT IP address is used when the same client accesses the same destination IP address. Otherwise, the client randomly selects an EIP or NAT IP address from the associated EIPs or NAT IP addresses. |
1 |
| NetworkInterfaceId |
string |
No |
The ID of the elastic network interface controller (NIC). Note
The IPv4 addresses of the elastic network interface controller (NIC) are used as the SNAT addresses. |
eni-gw8g131ef2dnbu3k**** |
| DryRun |
boolean |
No |
Specifies whether to only perform a dry run on the request. Valid values:
|
false |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The SNAT entry ID. |
||
| SnatEntryId |
string |
The ID of the SNAT entry. |
snat-kmd6nv8fy**** |
| RequestId |
string |
The ID of the request. |
2315DEB7-5E92-423A-91F7-4C1EC9AD**** |
Examples
Success response
JSON format
{
"SnatEntryId": "snat-kmd6nv8fy****",
"RequestId": "2315DEB7-5E92-423A-91F7-4C1EC9AD****"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | UnsupportedFeature.PrivateLinkEnabled | The feature of PrivateLinkEnabled is not supported. | |
| 400 | InvalidSourceCIDR.Malformed | SourceCIDR is illegal. | |
| 400 | NOT_ALLOW_USE_SOURCECIDR_OUTSIDEVPC | The User not in sourcecidr_unlimited_outsidevpc white list. Cannot use SourceCidr outside VpcCidr. | |
| 400 | NOT_ALLOW_USE_SOURCECIDR_AUTODEFINE | The User not in sourcecidr_unlimited_insidevpc white list. Cannot use SourceCidr auto defined. | |
| 400 | NOT_ALLOW_USE_SOURCECIDR_CONTAINSZERO | The User not in sourcecidr_unlimited_outsidevpc_containszero white list. Cannot use SourceCidr outside VpcCidr. | |
| 400 | Forbidden.IpHasBeenUsedInDnat | The snat ip can't be used. Because it has been used in dnat | |
| 400 | Forbidden.SourceVSwitchId.IncludeHaVip | There is some HaVips under specified VSwitch | The specified vSwitch is associated with HAVIPs. |
| 400 | InvalidSnatIp.Malformed | The specified SnatIp is not a valid IP address. | |
| 400 | SNAT_IP_POOL_COUNT_TOO_MANY | The Snat pool ip too many. | |
| 400 | Forbidden.SnatEntryCountLimited | SNAT entry in the specified SNAT table reach its limit. | The number of SNAT entries has reached the upper limit. |
| 400 | NOT_ALLOW_USE_SOURCECIDR | The User not in nat_scope_unlimited white list. Cannot use SourceCidr param. | |
| 400 | INVALID_PARAMETER | The parameter invalid. | |
| 400 | Forbidden.SourceVSwitchId.Duplicated | The specified SourceCIDRis duplicated. | |
| 400 | Forbidden.IpUsedInForwardTable | The specified SnatIp already used in forward table | |
| 400 | Forbindden | The specified Instance already bind eip | |
| 400 | EIP_NOT_SUPPORT_SNAT_POOL | The Eip cannot support snat pool | |
| 400 | EIP_NOT_IN_GATEWAY | The Eip not in nat gateway | |
| 400 | OperationUnsupported.CidrConflict | The specified CIDR block conflicts with an existing SNAT entry. | The specified CIDR block conflicts with those in existing SNAT entries. |
| 400 | InvalidNatGatewayId.NotFound | The NatGateway instance not exist. | |
| 400 | InvalidParameter.Name.Malformed | The specified Name is not valid. | |
| 400 | InvalidParameter.SnatIp | Ip semgment must be subnet cidr. | |
| 400 | QuotaExceeded.SnatIp | Public ip number exceeds quota. | |
| 400 | OperationUnsupported.EipInBinding | Create snat entry with eip in associating status is unsupported. | You cannot use an associated EIP when you create an SNAT entry. |
| 400 | OperationFailed.VSwitchNotInVpc | The specified vswitch and natgateway are not in the same vpc. | |
| 400 | QuotaExceeded.SnatEntry | SNAT entry in the specified SNAT table reach it?s limit. | |
| 400 | IncorrectStatus.NATGW | NATGW status is invalid. | The NAT gateway is in an invalid state. |
| 400 | IncorrectStatus.VSwitch | The specified vSwitch status is invalid. | The virtual switch status is abnormal. |
| 400 | MissingParam.SnatIp | The input parameter SnatIp that is mandatory for processing this request is not supplied. | You need to specify the SnatIp parameter when creating a Snat rule for public network NAT or private network NAT. |
| 400 | MissingParam.NetworkInterfaceId | The input parameter NetworkInterfaceId that is mandatory for processing this request is not supplied. | You need to specify NetworkInterfaceId parameters when creating a Snat rule for NAT with the private network link service enabled. |
| 400 | ParamExclusive.SnatIpAndNetworkInterfaceId | SnatIp and NetworkInterfaceId is mutually exclusive when create a snat entry for nat. | When you create an SNAT rule for a NAT Gateway instance, you cannot specify the SnatIp parameter and the NetworkInterfaceId parameter at the same time. |
| 400 | IllegalParam.NetworkInterfaceId | The param of NetworkInterfaceId is illegal. | Invalid NetworkInterfaceId value. |
| 400 | OperationUnsupported.EipNatBWPCheck | The EIP is not associated with a NAT service plan. | The EIP is not associated with a NAT service plan. |
| 400 | OperationUnsupported.EipNatGWCheck | The operation failed because the EIP is not bound to this NAT Gateway. | The operation failed because the EIP is not bound to this NAT Gateway. |
| 400 | OperationFailed.SnatIpPoolCbwpRules | The operation failed because the SNAT rule IPs are added to multi bandwidth packages. | The operation failed because the SNAT rule IP address pool was added to multiple bandwidth packages. |
| 400 | IncorrectStatus.SnatEntry | The SNAT rule status is invalid. Please try again later. | The SNAT rule is in the intermediate state, or the status is abnormal. Please try again later. |
| 400 | IncorrectStatus.NatIp | NatIp status is invalid, please try again later. | NatIp is in intermediate state, please try again later. |
| 400 | OperationUnsupported.EipNatIpCheck | The operation failed because the EIP is not bound to this NAT gateway. | The operation failed because the EIP is not bound to this NAT gateway. |
| 400 | OperationFailed.SnatIpPoolBwpRules | The operation failed because the IP in Snat entryl was added to multiple NAT bandwidth packets. | The operation failed because the IP in the SNAT rule IP address pool was added to multiple NAT bandwidth packets. |
| 400 | OperationFailed.SnatIpsCheck | The operation fails because some IPs address in the SNAT entry are not added to common bandwidth packet. | The operation fails because the IP address in the Snat rule IP address pool is not added to the shared bandwidth packet. |
| 500 | DefaultValidate.Error | validte fail. | |
| 500 | OperationFailed.CrateSnatEntryTimeOut | Operation failed because create snatEntry timeout. | |
| 404 | InvalidRegionId.NotFound | The specified RegionId does not exist in our records. | |
| 404 | InvalidSnatTableId.NotFound | Specified SNAT table does not exist. | |
| 404 | InvalidVSwitchId.NotFound | The specified virtual switch does not exists. | |
| 404 | InvalidSnatIp.NotFound | Specified SnatIp does not found on the NAT Gateway | |
| 404 | ResourceNotFound.NatGateway | The NatGateway instance not exist. | The NAT gateway does not exist. |
| 404 | ResourceNotFound.NatIp | The NatIp instance not exist. | |
| 404 | ResourceNotFound.VSwitch | The specified resource of %s is not found. | The specified vSwitch does not exist, please check your input is correct |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.