NAT & PAT Explained
Learn how Network Address Translation (NAT) and Port Address Translation (PAT) allow private devices to share a single public IP address.
The Problem NAT Solves
IPv4 addresses are 32 bits long, providing about 4.3 billion addresses. Because of the explosive growth of the internet, we ran out of unique public IPv4 addresses.
To solve this, NAT (Network Address Translation) was introduced. It allows an entire local network (LAN) containing hundreds of devices to share a single public IP address to access the internet.
NAT acts like a mailroom clerk in an office building. The building has one public mailing address, and the clerk routes incoming mail to specific desks.
How NAT Works (Step-by-Step)
- A device with private IP
192.168.1.5sends a packet to a website (public IP8.8.8.8). - The packet arrives at the router. The router sees the private source IP (which cannot be routed on the public internet).
- The router replaces the private source IP with its own public IP (e.g.,
203.0.113.1). - The router saves this mapping (private IP ↔ public IP) in its internal NAT Translation Table.
- The router sends the packet to the website.
- When the website replies, the packet arrives at the router's public IP.
- The router looks at its NAT table, translates the destination public IP back to the device's private IP (
192.168.1.5), and forwards it to the LAN.
Types of NAT
- Static NAT (One-to-One) — Maps a single private IP address to a single public IP address permanently. Commonly used for web servers hosted inside a private network that must be reachable from the outside.
- Dynamic NAT (Many-to-Many) — Maps private IP addresses to a pool of public IP addresses on a first-come, first-served basis.
- PAT (Port Address Translation / NAT Overload) — The most common type of NAT. Maps multiple private IP addresses to a single public IP address by assigning unique source port numbers to each session.
Port Address Translation (PAT) in Detail
Since multiple devices on a LAN might try to access the internet at the same time, the router uses ports to keep track of who gets what response:
- Device A (
192.168.1.5) sends traffic from port5000. Router translates it to: Public IP, port10001. - Device B (
192.168.1.10) sends traffic from port5000. Router translates it to: Public IP, port10002. - When responses return on ports
10001and10002, the router knows exactly which local IP to forward the packets to.
Benefits and Drawbacks of NAT
Benefits
- Conserves IP Addresses — Dramatically slows the depletion of IPv4 addresses.
- Security — Hides internal IP addresses from the public internet, making it harder for external attackers to target individual local computers.
Drawbacks
- Performance — Router has to unpack, translate, and repack every packet header, adding minor latency.
- End-to-End Traceability — Makes tracking the exact source device of network traffic more difficult.
- Compatibility — Certain protocols (like older VoIP systems) don't work well with translated ports without additional helper services.
What's Next?
Learn more about how routers manage IP assignments in IP Addressing & Subnetting, or see how packets travel across networks in Routing & Switching.