Skip to content
StackDecode
System Design
2. Networking FundamentalsAnimated

Network Address Translation (NAT)

Lets many private devices share one public IP address.

The idea

A NAT device rewrites source addresses and ports and remembers the mapping to return replies to the right device.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

Laptop 192.168.…Phone 192.168.1…NAT routerInternet
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Private devices share one public IP address.

step:
1/4
at:
Laptop 192.168.1.5
1/8

The green dot is a request moving through the system.

Step by step

  1. 1Private device sends a packet
  2. 2NAT replaces the source with its public address and a port
  3. 3Reply arrives at that port
  4. 4NAT maps it back to the device

Where it is used

Home routers and cloud private subnets.

Watch out for

Inbound connections do not work without port forwarding.

Related