NAT
Also known as: Network Address Translation
Network Address Translation — a technique that lets many devices on a private network share a single public IP address by rewriting source addresses and ports on outbound traffic.
Last updated:
What is NAT?
NAT (Network Address Translation) is a technique performed by routers that lets many devices on a private network share a single public IP address. Without NAT, each device would need its own globally routable IP, which IPv4 simply cannot provide — the 4.3 billion IPv4 addresses were exhausted in the 2010s. NAT is the reason your laptop, phone, smart TV, and every IoT device on your home Wi-Fi can reach the internet while the outside world sees just one public address.
How NAT works
When a device on the private network (e.g. 192.168.1.50) opens a connection to an external server, the NAT router:
- Rewrites the source IP on the outgoing packet from
192.168.1.50to the router's public IP - Rewrites the source port to a unique port on the router (e.g.
52341) - Records the mapping in its NAT table:
192.168.1.50:random_port ↔ public_ip:52341 - Reverses the rewrite on reply packets, so the response reaches the correct internal device
This specific variant — translating both address and port — is called PAT (Port Address Translation) or NAPT (Network Address Port Translation), and it's what virtually every home and office router uses.
Consequences of NAT
NAT works well for client-initiated traffic but complicates protocols that need inbound connections:
- Hosting a server from behind NAT requires port forwarding rules
- Peer-to-peer protocols (VoIP, gaming, WebRTC) need NAT traversal techniques like STUN, TURN, and ICE
- End-to-end encryption and connection identity become harder — many clients behind the same NAT look like one client from outside
- Logging and abuse reporting are muddied — a public IP doesn't uniquely identify a user when shared across hundreds of customers (CGNAT makes this much worse)
IPv6 was designed to eliminate the need for NAT by providing enough addresses for every device to have its own, but IPv4 plus NAT will remain the dominant deployment for years to come.