Create a NAT gateway.

Note the following before creating a NAT gateway:

  • A NAT gateway and a self-built SNAT gateway cannot coexist in a VPC.

  • After a NAT Gateway is created, a route entry of which the destination CIDR block is 0.0.0.0/0 and the next hop is the NAT Gateway is automatically added to the route table of the VPC. Therefore, traffic can be routed to the NAT gateway.

  • If a route entry of which the destination CIDR block is 0.0.0.0/0 already exists in the route table of the VPC, delete the router entry. Otherwise, the NAT gateway cannot be created.

Specification

NAT Gateway has different specifications.  Different specifications correspond to different SNAT performance metrics including Max Connection and CPS, but the specification does not affect data throughput.

The relationship between NAT gateway specification and SNAT performance is as follows:

Specification Max Connection  CPS
Small 10 thousand 1 thousand
Medium 50,000 5,000
Large 200,000 10,000
Super large 1,000,000 30,000

Request parameters

Name Type Required Description
Action String Yes

The action to perform. Valid value:

CreateNatGateway

RegionId String Yes

The region of the NAT Gateway.

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

VpcId String Yes

The ID of the VPC.

Spec String No
The specification of the NAT Gateway.  Valid value:
  • Small (default): small

  • Middle: medium

  • Large: large

  • Xlarge. 1: super large

BandwidthPackage.n.Bandwidth String No

The bandwidth of the n-th NAT bandwidth package. Valid value: [5,5000]

Note This API can only be called if your account purchased a NAT bandwidth package before January 26, 2018. If your account does not include a NAT bandwidth package before January 26, 2018, bind an EIP.
BandwidthPackage.n.Zone String No

The zone of the n-th NAT bandwidth package. The system randomly allocates a zone if the parameter is not specified.

If the NAT bandwidth package and the backend ECS instance are not in the same zone, the connectivity is not influenced; if they are in the same zone, the latency can be reduced.

Note This API can only be called if your account purchased a NAT bandwidth package before January 26, 2018. If your account does not include a NAT bandwidth package before January 26, 2018, bind an EIP.
Name String No

The name of the NAT Gateway.

The name  can contain from 2 to 128 characters including a-z, A-Z, 0-9, underlines, and hyphens. The name must start with an English letter, but cannot start with http:// or https://.

Description String No

The description of the NAT Gateway.

The description can contain from 2 to 256 characters. The description must start with English letters, but cannot start with http:// or https://.

ClientToken String No

A client token used to guarantee the idempotence of requests.

This parameter value is generated by the client and must be unique. It cannot exceed 64 ASCII characters.

Response parameters

Name Type Description
RequestId String The ID of the request.
NatGatewayId String The ID of the NAT Gateway.
ForwardTableIds String  The list of forwarding entries.
BandwidthPackageIds String The NAT bandwidth package of the NAT gateway.

Examples

Request example

https://vpc.aliyuncs.com/?Action=CreateNatGateway
&VpcId=vpc-11af8lp67
&Name=MyNatGW
&BandwidthPackage. 1. IpCount=5
&RegionId=cn-shanghai
&BandwidthPackage. 1. Bandwidth=150
&BandwidthPackage. 1. Zone=cn-shanghai-a
&CommonParameters
Response example
  • XML format

    <? xml version="1.0" encoding="UTF-8" ? >
                            <CreateNatGatewayResponse>
                            <BandwidthPackageIds>
                            <BandwidthPackageId>bwp-11odxu2k7</BandwidthPackageId>
                            </BandwidthPackageIds>
                            <ForwardTableIds>
                            <ForwardTableId>ftb-11tc6xgmv</ForwardTableId>
                            </ForwardTableIds>
                            <NatGatewayId>ngw-112za33e4</NatGatewayId>
                            <RequestId>2315DEB7-5E92-423A-91F7-4C1EC9AD97C3</RequestId>
                            </CreateNatGatewayResponse>
  • JSON format

    
      "BandwidthPackageIds": {
        "BandwidthPackageId": [
          "bwp-11odxu2k7"
        
      
      "ForwardTableIds": {
        "ForwardTableId": [
          "ftb-11tc6xgmv"
        
      
      "NatGatewayId": "ngw-112za33e4",
      "RequestId": "2315DEB7-5E92-423A-91F7-4C1EC9AD97C3"