DEV Community

Nagesh K
Nagesh K

Posted on

The Beginner’s Guide to NAT: Private vs Public IPs Made Simple

When I first started studying private and public IPs, I honestly didn’t realize how the internet actually worked behind the scenes. I thought my laptop was directly talking to YouTube. But the deeper I went, the more fascinating it became — and this step‑by‑step flow completely changed my understanding.

┌─────────────────────────────────────────┐
│ HOME NETWORK (LAN) │
├─────────────────────────────────────────┤
│ Laptop : 192.168.1.10 │
│ Phone : 192.168.1.11 │
│ Smart TV : 192.168.1.12 │
│ Tablet : 192.168.1.13 │
└─────────────────────────────────────────┘

│ Private IP Traffic

┌─────────────────────────────────────────┐
│ HOME ROUTER │
├─────────────────────────────────────────┤
│ LAN IP : 192.168.1.1 │
│ Public IP : 49.205.100.50 │
│ NAT Function Enabled │
└─────────────────────────────────────────┘


┌─────────────────────────────────────────┐
│ ISP NETWORK │
│ (Airtel / Jio / BSNL etc.) │
└─────────────────────────────────────────┘


┌─────────────────────────────────────────┐
│ INTERNET │
│ (Millions of interconnected networks) │
└─────────────────────────────────────────┘


┌─────────────────────────────────────────┐
│ YOUTUBE SERVERS │
│ Public IP Reachable │
└─────────────────────────────────────────┘

Detailed Request Flow :

Suppose your laptop opens YouTube.

Step 1

Browser : youtube.com

Step 2

DNS Lookup
youtube.com

142.x.x.x
Browser now knows YouTube's IP.

Step 3

Laptop creates packet
Source IP : 192.168.1.10
Destination IP : 142.x.x.x

Step 4

Packet reaches Router
Laptop

Router

Router sees:
Source IP = 192.168.1.10
This is private.
Cannot travel on Internet.

Step 5

Router performs NAT
Changes : 192.168.1.10 into 49.205.100.50

Now packet becomes:
Source IP : 49.205.100.50
Destination IP : 142.x.x.x

Router remembers:
49.205.100.50 ↔ 192.168.1.10
inside NAT Table.

Step 6

Router sends packet
Router

ISP

Internet

YouTube

What YouTube Sees
YouTube sees:
Source IP : 49.205.100.50 NOT 192.168.1.10

Therefore:
YouTube does NOT know
Laptop IP = 192.168.1.10
YouTube only knows
Router Public IP = 49.205.100.50

Response Flow

YouTube sends response:
Source IP : 142.x.x.x
Destination IP : 49.205.100.50

Response travels:
YouTube

Internet

ISP

Router
Router receives response

Router checks NAT table:
49.205.100.50

192.168.1.10

Router now knows : This response belongs to Laptop.

Router forwards packet
Router

Laptop

Laptop receives:
Video Chunks
HTML
CSS
JavaScript
Images

Browser renders everything, You watch YouTube.

The Most Important Takeaway

Many Private IPs

Router
(NAT)

One Public IP

Internet

Example:
192.168.1.10
192.168.1.11
192.168.1.12
192.168.1.13

NAT Router

49.205.100.50
All devices share one Public IP.

🚀 Final Reflection
When I first studied private and public IPs, I didn’t know the internet worked this way. But now, with this mental model, I can clearly see how NAT allows multiple devices to share one public IP while keeping private IPs hidden inside the network.

This is the foundation every beginner must master before diving deeper into cloud networking and AWS concepts.

Top comments (0)