skip to content
Kushalgouda Patil
Table of Contents

The quiet trick that kept the internet alive when the world ran out of addresses.

The Problem NAT Solves

When IPv4 was designed, 4.3 billion addresses seemed infinite. It wasn’t. As the internet exploded through the 1990s, it became obvious the world would run out of public IP addresses well before everyone was done connecting to it.

NAT was the elegant stopgap. Instead of assigning a unique public IP to every device, we assign one to the router and let every device behind it share it.

Private vs Public IPs: The Foundation

Private IP addresses are reserved ranges that anyone can use internally — 192.168.0.0/16, 10.0.0.0/8, and 172.16.0.0/12. They are free, reusable, and invisible to the public internet.

Public IP addresses are globally unique, assigned by ISPs, and routable across the internet. Your ISP gives your router one of these — just one.

NAT lives at the boundary between these two worlds.

How NAT Actually Works

When your laptop wants to load a webpage, the router acts as a translator standing between your private network and the public internet. Here is the flow:

  1. Your laptop (192.168.1.5) sends a request to Google (142.250.80.46).
  2. The router intercepts the packet and replaces the private IP with its public IP (203.0.113.10), assigning it a port number to track the connection.
  3. The request goes out to the internet looking like it came from the router.
  4. Google responds to the router’s public IP.
  5. The router checks its table, finds who originally made that request, and forwards the response to your laptop.

The NAT Translation Table

Private IPPrivate PortPublic IPPublic PortDestination
192.168.1.552341203.0.113.1010001142.250.80.46 (Google)
192.168.1.849201203.0.113.1010002104.244.42.1 (x.com)
192.168.1.1261345203.0.113.101000313.107.42.14 (Microsoft)

Types of NAT

TypeHow it worksReal world use
Static NATOne private IP maps to one fixed public IPHosting a server that needs a permanent address
Dynamic NATPrivate IPs draw from a pool of public IPsOffices with a small block of public IPs
PAT (NAT Overload)Many private IPs share one public IP via portsYour home router — the most common type

The Tradeoffs

  • Inbound connections are hard. The router only creates table entries when your device initiates a connection. If an outside machine tries to reach a device inside your network, there is no entry to match it — the packet gets dropped. This is why hosting a game server or using peer-to-peer apps often requires port forwarding.

  • It breaks the end-to-end principle. The internet was originally designed so any device could talk directly to any other. NAT puts a middleman in the way, which complicates VoIP, gaming, and file sharing.