Skip to Content

NAT instance and NAT gateway

How NAT gives private subnets outbound internet access, the outdated NAT instance, the managed NAT gateway and its high availability, the Regional NAT gateway, and the comparison.

NAT instance

A NAT instance: private instances 10.0.0.10 and 10.0.0.20 route 0.0.0.0/0 to a NAT instance in the public subnet, which has an Elastic IP and source/destination check turned off; it rewrites the source address to its Elastic IP and forwards the traffic to the internet server A NAT instance: private instances 10.0.0.10 and 10.0.0.20 route 0.0.0.0/0 to a NAT instance in the public subnet, which has an Elastic IP and source/destination check turned off; it rewrites the source address to its Elastic IP and forwards the traffic to the internet server

Outdated, but still on the exam.

NAT = Network Address Translation. A NAT instance is an EC2 instance that performs the translation.

  • Allows EC2 instances in private subnets to connect to the internet (outbound only: the internet can't start connections to them).
  • Must be launched in a public subnet.
  • Must disable the EC2 setting source / destination check (it forwards traffic that isn't for itself).
  • Must have an Elastic IP attached to it.
  • Route tables must be configured to route traffic from private subnets to the NAT instance.

Comments:

  • A pre-configured Amazon Linux NAT AMI was available, but it reached the end of standard support on 31 December 2020.
  • Not highly available / resilient out of the box: it needs an ASG in multiple AZs and a resilient user-data script.
  • Internet traffic bandwidth depends on the EC2 instance type.
  • The customer must manage security groups and rules:
    • inbound: allow HTTP/HTTPS traffic coming from private subnets; allow SSH from the admin's home network (through the internet gateway);
    • outbound: allow HTTP/HTTPS traffic to the internet.

NAT gateway

A NAT gateway is AWS-managed NAT: higher bandwidth, high availability, no administration.

  • Pay per hour for usage and per GB of data processed.
  • A NAT gateway is created in a specific Availability Zone and uses an Elastic IP.
  • It can't be used by EC2 instances in the same subnet (only from other subnets).
  • Requires an IGW (private subnet → NAT gateway → IGW).
  • 5 Gbps of bandwidth with automatic scaling up to 100 Gbps.
  • No security groups to manage or required.

High availability

NAT gateways for high availability: each Availability Zone has its own NAT gateway in its public subnet, and each private subnet routes to the NAT gateway in its own AZ, which reaches the internet through the internet gateway; if one AZ fails, the other AZ keeps working NAT gateways for high availability: each Availability Zone has its own NAT gateway in its public subnet, and each private subnet routes to the NAT gateway in its own AZ, which reaches the internet through the internet gateway; if one AZ fails, the other AZ keeps working

One NAT gateway per AZ.
  • A NAT gateway is resilient within a single Availability Zone.
  • Multiple NAT gateways in multiple AZs are needed for fault tolerance.
  • There's no cross-AZ failover needed: if an AZ goes down, its instances are down too and don't need NAT.

Regional NAT gateway

A Regional NAT gateway: one NAT gateway for the VPC expands automatically to every Availability Zone with workloads and has its own route table to the internet gateway; private subnets in AZ A and AZ B route to it without any public subnet A Regional NAT gateway: one NAT gateway for the VPC expands automatically to every Availability Zone with workloads and has its own route table to the internet gateway; private subnets in AZ A and AZ B route to it without any public subnet

One NAT gateway that follows the workloads across AZs.

A Regional NAT gateway (the slides call it RNAT) is a highly available NAT gateway associated with the VPC, instead of one AZ.

  • It has its own route table (to the IGW).
  • It removes the need for per-AZ deployments: one NAT gateway shared across AZs.
  • The VPC doesn't need public subnets to host it.
  • It automatically detects resources in a new AZ and expands to it.
  • It's charged per hour for each AZ it's active in, plus per GB.
  • Regional NAT gateways are for public internet access only; for private NAT (to other VPCs or on premises), use zonal NAT gateways.

NAT gateway vs NAT instance

NAT gateway:

  • availability: highly available within an AZ (create one per AZ, or use a Regional NAT gateway);
  • bandwidth: up to 100 Gbps;
  • maintenance: managed by AWS;
  • cost: per hour and amount of data processed;
  • no security groups; can't be used as a bastion host.

NAT instance:

  • availability: failover between instances is scripted by the customer;
  • bandwidth: depends on the EC2 instance type;
  • maintenance: managed by the customer (software, OS patches…);
  • cost: per hour, EC2 instance type and size, plus network;
  • security groups apply; can be used as a bastion host.

Both support public and private IPv4.

Real-world examples

  • A company runs app servers in private subnets in three AZs, with a NAT gateway in each AZ so the servers can download OS updates. Later it switches to one Regional NAT gateway and deletes the public NAT subnets.

Exam tips

  • "Private instances need outbound internet (patches, APIs), no inbound" → NAT gateway.
  • "Highly available NAT" → one NAT gateway per AZ, each AZ's private subnets routing to their own (or a Regional NAT gateway).
  • "NAT instance not working" → disable source/destination check, Elastic IP, route table, security groups.
  • "Least operational overhead" → NAT gateway, not NAT instance.
  • "IPv6 outbound only" → egress-only internet gateway, not NAT (see IPv6).

Common traps

  • "One NAT gateway serves all AZs with no risk." A zonal NAT gateway fails with its AZ.
  • "Attach a security group to the NAT gateway." It doesn't support security groups.
  • "Put the NAT gateway in the private subnet." A (zonal, public) NAT gateway sits in a public subnet.

Check yourself

A NAT gateway costs about $0.045 an hour plus $0.045 per GB, so instead:

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt