If you open your command prompt and type `ipconfig`, you probably see `192.168.1.5`. But if you go to "whatismyip.com", you see `142.55.22.99`. Why do you have two identities? The answer lies in the scarcity of IPv4 addresses.
Public IP (The Passport)
- Assigned to you by your ISP (Verizon, Comcast). - Globally Unique: No one else in the world has it. - Routable: Packets can travel from Japan to this IP. - You usually get only ONE for your entire house.
Private IP (The Room Number)
- Assigned by your Router (DHCP). - Locally Unique: Your neighbor also uses 192.168.1.5, and that's fine. - Non-Routable: The internet backbone routers are programmed to drop these packets immediately. - Used for LAN communication (printing, file sharing).
1. NAT (Network Address Translation)
Your router acts as the translator.
1. Your phone (192.168.1.5) sends a request to Google.
2. The Router intercepts it. It replaces the specific "From: 192.168.1.5" with "From: [Public IP]".
3. Google replies to the Public IP.
4. The Router remembers: "Oh, this reply is for the Phone". It forwards it back to 192.168.1.5.
2. RFC 1918 Ranges (Memorize These)
You cannot just pick any IP for private use. You must use these reserved blocks:
- 10.0.0.0 - 10.255.255.255: Large networks (Enterprise).
- 172.16.0.0 - 172.31.255.255: Medium networks (AWS uses this often).
- 192.168.0.0 - 192.168.255.255: Small networks (Home Routers).
3. CGNAT (Carrier Grade NAT)
Sometimes, even your "Public" IP isn't truly public.
Mobile carriers use CGNAT. Your phone sits behind a giant router at the ISP level, sharing a Public IP with thousands of other strangers.
This makes hosting servers (or using Port Forwarding) impossible on 4G/5G connections.