Concepts / Cloud networking

Cloud networking

Internet gateway and NAT gateway

Also called internet gateway, IGW, NAT gateway, elastic IP, public IP, virtual private gateway, Direct Connect, ExpressRoute, VPC peering

The VPC's doors: one-to-one public IPs both ways through the internet gateway, and outbound-only overload through a NAT gateway.

The internet gateway maps each instance's public (elastic) IP to its private address, both ways: static NAT, held in the gateway, so the instance never sees its public address and the IP can move to another instance in a moment. An instance without one gets no internet, even in a public subnet. A NAT gateway sits in a public subnet with a public IP of its own and overloads (PAT) a private subnet onto it: replies come back, new connections from the internet do not. To join your own network, a site-to-site VPN (a virtual private gateway, IPsec over the internet) is quick and cheap; a direct connect (AWS Direct Connect, Azure ExpressRoute) is a private circuit with steady bandwidth and latency. VPC peering joins two VPCs privately: it carries nothing until each VPC's route table points at it, it needs address blocks that don't overlap, and it never passes traffic on to a third VPC.

Rewritten twice on the way out
Rewritten twice on the way out

A private server's request leaves through two gateways: the NAT gateway puts its own address on it, and the internet gateway swaps that for an elastic IP. The answer is rewritten back in the other order. From the Cloud routing: how a private subnet gets out, and how two VPCs meet lab.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab