We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
This idea carries a full system design question on its own. Each walks through the full answer.
System Design Masterclass · Cloud Infrastructure
Free preview: the first 2 parts of this 7-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Cloud Infrastructure
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
Your house probably has a dozen devices connected to the internet, laptop, phone, tablet, smart TV, game console, maybe a few IoT gadgets. Each one has its own IP address. But your ISP only gave you one public IP.
How does this work? How do a dozen devices share a single address?
The answer is NAT. Network Address Translation. Your router maintains a translation table, rewriting the source address on every outgoing packet from the device's private IP to the router's public IP (and a unique port number). When the response comes back, the router checks the port, looks up the table, and forwards it to the right device.
This trick is why we haven't completely exhausted IPv4 addresses despite having billions of connected devices. It's also the foundation of how cloud networking works. Every private subnet in AWS, Azure, or GCP uses NAT to give instances internet access without exposing them publicly. If you don't understand NAT, you'll spend hours debugging why your EC2 instance in a private subnet can't download packages.
Static NAT (1:1): One private IP maps permanently to one public IP. Used when a server behind the NAT needs to be reachable from the outside, like a web server.
Dynamic NAT: Private IPs are mapped to public IPs from a pool on a first-come, first-served basis. When the session ends, the public IP goes back to the pool.
PAT (Port Address Translation) / NAT Overload: The most common type. Many private IPs share a single public IP, distinguished by unique port numbers. This is what your home router does. Also called "masquerading" in Linux.
| Type | Ratio | Use Case |
|---|---|---|
| Static NAT | 1:1 | Servers that need fixed public addresses |
| Dynamic NAT | N:M (pool) | When you have a pool of public IPs |
| PAT / Overload | N:1 | Home networks, cloud private subnets |
How PAT works in detail: