edit-icon download-icon

CreateSnatEntry

Last Updated: Apr 12, 2018

Description

Add an SNAT entry in an SNAT table.

Each SNAT entry consists of SourceVSwitchId and SnatIp. After an SNAT entry is added, ECS instances under the specified VSwitch can access the Internet using the public IP (SnatIp).

Note the following before creating an SNAT entry:

  • The VSwitch in the SNAT entry must meet the following requirements:

    • The VSwitch must belong to the same VPC as the NAT gateway.

    • The SNAT entry cannot be added if there is any HaVip instance under the VSwitch.

    • Each VSwitch can belong to only one SNAT entry.

  • The public IP (SnatIp) in the SNAT entry must meet the following requirements:

    • If your account has a NAT bandwidth package before 23:59, January 26, 2018, SnatIp must be a public IP address in the NAT bandwidth package of the NAT gateway.

    • An EIP cannot be used in a DNAT entry and an SNAT entry at the same time, but can be used by multiple SNAT entries.

    • If your account does not have a NAT bandwidth package before 23:59, January 26, 2018, SnatIp must be an EIP bound to the NAT gateway. For more information, see Bind EIPs.

Request parameters

Name Type Required Description
Action String Yes

The action to perform.

Valid value: CreateSnatEntry

RegionId String Yes

The region of the NAT gateway.

You can obtain the region ID by calling the DescribeRegions API.

SnatTableId String Yes The ID of the SNAT table.
SourceVSwitchId String Yes The ID of the VSwitch.
SourceCIDR String No

The CIDR block of the VSwitch, such as 10.1.1.0/24.

Note: This parameter and the SourceVSwitchId parameter cannot be specified at the same time.

SnatIp String Yes

The public IP address.

Separate multiple EIPs by commas, such as 47.XXX.XXX.98,47.XXX.XXX.99,47.XXX.XXX.241.

Response parameters

Name Type Description
RequestId String The ID of the request.
SnatEntryId String The ID of the SNAT entry.

Error codes

See VPC API Error Center.

Examples

Request example

  1. https://vpc.aliyuncs.com/?Action=CreateSnatEntry
  2. &RegionId=cn-shanghai
  3. &SnatTableId=stb-gz3r3odaw
  4. &SnatIp=139.224.22.40
  5. &SourceVSwitchId=vsw-yrv0winkw
  6. <CommonParameters>

Response example

JSON format

  1. {
  2. "RequestId": "69B31D6E-9F34-4A5A-8DBC-230A3918E828",
  3. "SnatEntryId": "snat-kmd6nv8fy"
  4. }
Thank you! We've received your feedback.