Internet gateway

On this page 7

An internet gateway is a horizontally scaled, provider-managed component of cloud networking that attaches to a virtual private cloud (VPC) and gives its resources a path to and from the public internet. It serves as the target of a default route, typically 0.0.0.0/0 for IPv4 and ::/0 for IPv6, and performs one-to-one translation between private addresses and the public addresses assigned to instances.

The term is most closely associated with AWS, where it is an explicit resource, but every major cloud provides the same function. In Azure and Google Cloud, internet access is handled by system routes and the default internet gateway rather than by a resource that users attach by hand.

How an internet gateway routes traffic

An internet gateway works only together with route tables and public addresses. A subnet becomes a public subnet when its route table sends internet-bound traffic to the gateway; a subnet without that route remains private even if the VPC has a gateway attached.

For IPv4, an instance never sees its public address on its own network interface. When it sends a packet to the internet, the gateway rewrites the private source address to the associated public IPv4 or Elastic IP address, and reverses the translation for replies. This is static one-to-one NAT, not the many-to-one port translation that a NAT gateway performs. For IPv6, addresses are globally routable, so the gateway forwards packets without translation.

RequirementWhere it is configuredWhat fails without it
Gateway attached to the VPCVPC resourceNo internet path exists at all
Default route to the gatewaySubnet route tableTraffic stays inside the VPC
Public IPv4 or IPv6 addressInstance or network interfaceNo translatable source address
Permissive security groupInstance-level firewallPackets dropped at the instance
Permissive network ACLSubnet-level filterPackets dropped at the subnet edge
Conditions for internet reachability through a gateway

A VPC can have only one internet gateway attached at a time, and the gateway is highly available by design: there is no instance to size, patch or place in an availability zone, and it imposes no bandwidth limit of its own.

Internet gateway compared with neighboring components

An internet gateway is one of several edge components that move traffic in and out of a VPC. Each answers a different question about direction, address type and destination, and confusing them is a common design error.

ComponentDirectionTranslationTypical purpose
Internet gatewayInbound and outboundOne-to-one for IPv4Public subnets, internet-facing hosts
NAT gateway / Cloud NATOutbound onlyMany-to-one with portsPrivate subnets reaching updates and APIs
Egress-only internet gatewayOutbound only, IPv6NonePrivate IPv6 workloads
VPN gatewayBoth, to a named peerUsually noneEncrypted link to on-premises networks
Transit gatewayBetween networksNoneHub for many VPCs and connections
Private endpointTo a specific serviceNoneReaching cloud services without the internet
Edge components in cloud networking

Note that a managed NAT gateway itself sits in a public subnet and sends its traffic through the internet gateway. Private instances therefore reach the internet in two hops: private subnet to NAT gateway, then NAT gateway to internet gateway.

Designing public and private subnets

The standard pattern is to expose as little as possible through the internet gateway. Only components that must accept connections from the internet belong in public subnets, and everything else stays private behind them.

WorkloadSubnet typeInternet path
Public load balancerPublicInbound via internet gateway
Application serversPrivateOutbound via NAT, inbound via load balancer
DatabasesPrivate, isolatedNone, or private endpoints only
Bastion hostPublic, tightly filteredInbound SSH from known ranges
NAT gatewayPublicOutbound via internet gateway
Where common workloads belong

Many organizations now replace bastion hosts with session manager or identity-aware proxy services, which remove the need for any inbound administrative port. A useful rule of thumb is that a database with a public IP address is a design defect, regardless of firewall rules.

Cost, logging and security considerations

An internet gateway usually has no hourly charge, but traffic leaving the cloud through it is billed as data transfer out, often called egress fees. On some providers, public IPv4 addresses are now billed per hour, which makes address inventory a cost topic as well as a security one.

  • Flow visibility: VPC flow logs record accepted and rejected connections at the interface level, which is the main evidence for traffic through the gateway.
  • Filtering: the gateway does not inspect traffic; filtering is the job of security groups, network ACLs and cloud firewalls.
  • Centralized inspection: some architectures route internet traffic through an inspection VPC with firewall appliances instead of giving every VPC its own gateway.
  • Guardrails: organization policies can forbid attaching internet gateways to sensitive accounts entirely.

Common mistakes and troubleshooting

Most connectivity incidents involving an internet gateway come from one missing link in the chain rather than from the gateway itself. The table maps typical symptoms to their usual cause.

SymptomLikely causeFix
Instance unreachable from the internetNo public address assignedAssociate a public or Elastic IP
Outbound traffic times outRoute table lacks the default routeAdd a route to the internet gateway
Private instances cannot updateNo NAT pathAdd a NAT gateway and private route
Only replies are blockedStateless ACL missing ephemeral portsAllow ports 1024 to 65535 outbound
Unexpected exposure of a serviceResource placed in a public subnetMove it to a private subnet
Troubleshooting internet connectivity

Explained without jargon

A cloud network is like a private office building with no doors to the street. An internet gateway is the main entrance that connects the building to the outside world.

Having the entrance is not enough on its own. Each room also needs signs pointing to the door, which are the routes, and a public street address, so that visitors can find it. Rooms without those signs stay private, which is exactly how sensitive systems such as databases are kept away from the internet.

A typical use case

An online store runs in a VPC with the address range 10.0.0.0/16. Two public subnets, one per availability zone, hold the load balancer and a NAT gateway, and their route tables send 0.0.0.0/0 to the internet gateway. Six application servers and a database cluster sit in private subnets with no public addresses.

Customers reach the load balancer through the internet gateway, the load balancer forwards requests to the application servers, and those servers download security patches through the NAT gateway. When an auditor scans the public address space, only ports 80 and 443 on the load balancer respond, and the database is not reachable from the internet at all.