Private vs Public IP Addresses
Learn the difference between private and public IP addresses, RFC 1918 ranges, and how NAT connects them — interview Q&A.
Expected Interview Answer
A public IP address is globally unique and directly routable across the internet, while a private IP address comes from reserved ranges (like 10.0.0.0/8 or 192.168.0.0/16) that are only meaningful within a local network and are never routed on the public internet.
Private ranges defined by RFC 1918 — 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 — can be reused independently by millions of separate home and office networks because routers on the public internet are configured to drop packets addressed to them, so there is no global collision. Devices behind a private network reach the internet through Network Address Translation (NAT), where a router rewrites each outgoing packet’s private source address to its own single public address and tracks the mapping so return traffic gets routed back to the correct internal device. This design conserves the limited pool of public IPv4 addresses and adds a natural layer of isolation, since external hosts cannot directly initiate a connection to a private address without port forwarding or a NAT traversal technique. IPv6's vastly larger address space reduces the pressure that made NAT necessary, though private addressing concepts still apply for network segmentation.
- Conserves scarce public IPv4 address space via reuse across networks
- NAT lets many private devices share one public IP for outbound traffic
- Provides a natural isolation layer against unsolicited inbound connections
- RFC 1918 ranges are reserved and never routed on the public internet
AI Mentor Explanation
A private IP is like a squad’s internal jersey numbers used only within team practice sessions, while a public IP is like the player’s officially registered international cap number recognized across every ground worldwide. Two different domestic squads can both have a "number 7" in practice without any conflict, just as two homes can both use 192.168.1.7 without clashing. When a player steps onto the international stage, the team manager, like a NAT router, presents them under their single recognized cap identity to the outside world. The internal number only ever makes sense inside that squad’s own dressing room.
Step-by-Step Explanation
Step 1
Private assignment
A router assigns devices addresses from a reserved RFC 1918 range (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16).
Step 2
Local-only routing
Private addresses are only meaningful and routable within that local network segment.
Step 3
NAT translation
When traffic leaves the network, the router rewrites the private source address to its single public IP.
Step 4
Return mapping
The router tracks the translation table so response traffic is routed back to the correct internal device.
What Interviewer Expects
- Names the RFC 1918 private ranges correctly
- Explains that private addresses are never globally routable
- Understands NAT as the mechanism connecting private networks to the public internet
- Knows public IPs must be globally unique while private ones can be reused
Common Mistakes
- Thinking a private IP is unique across the entire internet
- Confusing NAT with a VPN or firewall
- Not knowing the specific RFC 1918 reserved ranges
- Assuming external hosts can always reach a private IP directly without port forwarding
Best Answer (HR Friendly)
“A private IP address is like an internal extension number that only works inside your home or office network, while a public IP address is the single number your internet provider gives your router that the rest of the world actually sees. Your router quietly translates between the two through a process called NAT, which is how dozens of devices on your Wi-Fi can all share one public IP address while browsing the internet at the same time.”
Code Example
# Show this machine’s private (local) IP address
ip -4 addr show | grep inet
# Example: 192.168.1.42 -- a private RFC 1918 address
# Look up the public IP address this machine is seen as on the internet
curl -s https://api.ipify.org
# 203.0.113.77 -- the public address after NAT translationFollow-up Questions
- What are the three RFC 1918 private IP address ranges?
- How does NAT let multiple devices share one public IP address?
- Why can two different home networks both use 192.168.1.1?
- How does port forwarding let an external host reach a device behind NAT?
MCQ Practice
1. Which of these is a private IP address range?
192.168.0.0/16 is one of the three RFC 1918 reserved private address ranges.
2. What mechanism allows multiple private IPs to share one public IP?
NAT rewrites private source addresses to a shared public address and tracks return mappings.
3. Why can two unrelated home networks both use 192.168.1.1 with no conflict?
Private addresses are never routed on the public internet, so they only need to be unique within their own local network.
Flash Cards
RFC 1918 private ranges? — 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16.
Can private IPs collide across networks? — Yes, harmlessly — they are only meaningful within their own local network.
What connects a private network to the public internet? — NAT, which translates private addresses to a shared public IP.
Public IP uniqueness requirement? — Must be globally unique and routable across the internet.