Skip to main content

NAT Gateway

A NAT Gateway lets the resources in a subnet access the internet while preventing external networks from connecting directly to them. For example, a server that only needs to download software packages or call external APIs connects to the internet through a NAT Gateway, without being reachable from outside.

How a NAT Gateway Works​

Connections through a NAT Gateway are one-way and outbound only (egress): the subnet's resources can connect to the internet, but external networks can't connect to them. This way, you don't need to give each server a public IP, and all outbound traffic leaves through one IP, the NAT Gateway's Elastic IP. This method is called SNAT (Source NAT).

If a server receives public traffic (for example, a web server), use an Elastic IP on the server itself instead of a NAT Gateway. If a server needs the internet for updates or calling external APIs but shouldn't be visible from outside, a NAT Gateway is the right choice. If a server only works with resources inside the VPC, you don't need either, and its network stays fully private.

Creating a NAT Gateway​

Before creating a NAT Gateway, internet access (Network Gateway) must be enabled on the VPC. The guide to creating a VPC helps you with this.

  1. In the Arvancloud panel, go to the VPC section and select NAT Gateway from the menu.
  2. Click the New NAT Gateway button.
  3. Region: select the region you want to create the NAT Gateway in.
  4. NAT Gateway name: enter an English name for the NAT Gateway.
  5. Subnet: select the subnet whose outbound traffic should go through this NAT Gateway. Only subnets with the Available status are shown in the list.
  6. Elastic IP: each NAT Gateway needs an Elastic IP to connect to the internet. If you have already created an Elastic IP, select it from the list; otherwise, click Allocate New IP.

If the Elastic IP you want isn't shown in the list, it's probably in another AZ or already attached to another resource. In that case, allocate an IP in the same AZ as this subnet, or detach its previous attachment.

  1. Click the Confirm button.

After the NAT Gateway is active, the subnet's outbound traffic goes to the internet through the NAT Gateway and its Elastic IP.

Note that a NAT Gateway is created in one subnet and one AZ. If that AZ becomes unavailable, internet access through this NAT Gateway is also cut off.

Checking the Outbound Connection​

To check the connection, run the following command from a server inside the subnet:

curl https://ifconfig.me

The returned IP should be the Elastic IP attached to the NAT Gateway. If the command gets no response or returns an error, check that internet access (Network Gateway) is enabled on the VPC; otherwise, the subnet's servers can't reach the internet even after the NAT Gateway is created.

If you can't connect to a private server from outside, it's because a NAT Gateway only supports outbound traffic. For inbound access, you need to attach an Elastic IP to the server itself.

Deleting a NAT Gateway​

Before deleting, make sure no service depends on the NAT Gateway, because deleting it immediately cuts off the internet connection of all resources attached to it. Then, in the NAT Gateway list, click the three-dot menu of the NAT Gateway and select Delete NAT Gateway.

As long as a NAT Gateway exists in a subnet or VPC, that subnet or VPC can't be deleted. If you can't release an Elastic IP, the IP is still attached to the NAT Gateway; first delete the NAT Gateway and then release the IP.

Limits​

LimitValue
Number of NAT Gateways per subnet1 (up to 4 on request)
Number of Elastic IPs per NAT Gateway1

Pricing​

Creating a NAT Gateway is free, but the Elastic IP attached to it is charged monthly (pay-as-you-go). Outbound (upload) traffic from a server to the internet is free.