Public vs. Private IP Addresses & NAT
Let's shift gears. Now that you know how an IP is built, we need to talk about the two different "worlds" these IPs live in: the Private world of your home/office and the Public world of the open internet.
2. Public vs. Private IP Addresses
1. One-line definition
Private IP ranges are specific blocks of addresses reserved for use within local networks and are never allowed to travel on the public internet.
2. Why it exists
It prevents global chaos. By setting aside these "private" numbers, millions of businesses and homes can use the exact same addresses internally without interfering with each other.
3. Break into components
- Class A Private: 10.0.0.0 to 10.255.255.255 (Huge networks)
- Class B Private: 172.16.0.0 to 172.31.255.255 (Medium networks)
- Class C Private: 192.168.0.0 to 192.168.255.255 (Small/Home networks)
4. Explain each component
Class A (10.x.x.x): Used by giant corporations or labs. It provides over 16 million addresses.
Analogy: Think of a massive skyscraper with thousands of offices.
Class B (172.16.x.x): Used by universities or large office buildings.
Analogy: Think of a large suburban high school with many classrooms.
Class C (192.168.x.x): This is what you see at home. Itโs for small setups.
Analogy: Think of a single-family house.
5. How it works
- A standard (RFC 1918) was created to "blacklist" these numbers from the public internet.
- Public routers are programmed to drop any packet that says it's coming from a private IP.
- Because they are "blocked" from the public web, everyone can use them safely at home.
6. Show how they connect
Now that you know these addresses are "trapped" inside your house, you might wonder: "How do I get on Google if my IP is private?" Thatโs where NAT comes in.
7. Give TWO real examples
Example 1 (Basic): Check your phone's Wi-Fi settings right now. Youโll likely see 192.168.x.x or 10.x.x.x. Your friend at their house likely has the exact same IP address. You don't crash because you're both in your own "private bubbles."
Example 2 (Cybersecurity): During a Pentest, if a hacker gains access to a web
server and runs ifconfig, seeing a 10.x.x.x address is like finding a gold mine. It
means they are officially inside the internal network and can now start attacking other private
servers that the public can't see.
2c-i. Why NAT exists
1. One-line definition
NAT is a process where your router swaps your device's Private IP for the router's single Public IP so you can communicate with the outside world.
2. Why it solves the problem
It allows hundreds of devices in your home or office to share one expensive Public IP address, effectively hiding your internal network from the internet.
3. Break into components
- The Inside Local: Your device's private identity (e.g., 192.168.1.15).
- The Outside Global: The router's public identity that the world sees (e.g., 92.4.55.101).
- The NAT Table: The "ledger" the router keeps to remember who asked for what.
4. Explain each component using analogies
The Inside Local: This is your name within your family (e.g., "Junior").
Analogy: Everyone in your house knows who "Junior" is, but the mailman doesn't.
The Outside Global: This is your familyโs shared last name and street address.
Analogy: To the post office, you are just "The Smith Family at 123 Main St."
The NAT Table: This is the "brain" of the router.
Analogy: Like a restaurant host who remembers that Table 5 ordered the steak and Table 2 ordered the pasta. When the food comes out of the kitchen, the host knows exactly which table to give it to.
5. How it works
- Your laptop (192.168.1.5) sends a request to visit Google.
- The packet hits your Router.
- The Router strips off your private IP and sticks its Public IP on the packet.
- The Router notes in its NAT Table: "Port 5001 is actually the laptop at .1.5."
- Google sends the data back to the Public IP.
- The Router checks the table, sees Port 5001, and passes the data to your laptop.
6. Show how they connect
Now that you see how NAT acts as a middleman, you can see why it's also a basic security feature: nobody on the internet can "knock" on your laptop's door directly because they can only see the router's door.
7. Give TWO real examples
Example 1 (Basic): When you and your roommate both check Instagram at the same time, you both look like you are coming from the exact same IP address to Instagram's servers. Your router uses NAT to make sure your roommate's feed doesn't end up on your phone.
Example 2 (Cybersecurity): In Defensive Security, NAT acts as a "poor man's firewall." Since your private IP isn't reachable from the outside, an attacker can't easily scan your specific PC unless you "port forward" (open a hole) or they trick you into making an outgoing connection first (like clicking a malicious link).
2c-ii. The "Mailroom" Analogy
1. One-line definition
The Mailroom Analogy compares a local network to an apartment building where everyone shares one street address but has individual room numbers.
2. Why it exists
NAT can feel like abstract "math" until you visualize it as physical mail being sorted and redirected by a middleman.
3. Break into components
- The Apartment Units: The private devices in your home.
- The Mailroom Clerk: The Router performing NAT.
- The Building Address: The Public IP address.
- The Return Label: The process of translating the address.
4. Explain each component
The Apartment Units: Each unit has its own internal number (e.g., Unit 101, 102).
Analogy: These are like your Private IPs (192.168.1.10). They only work inside the building.
The Mailroom Clerk: A person who sits at the front desk and handles all incoming and outgoing mail.
Analogy: This is your Router. It is the only one who talks to the mailman (the Internet).
The Building Address: The official address registered with the city (e.g., 500 Security Way).
Analogy: This is your Public IP. To the rest of the world, everyone in the building lives at this one spot.
5. How it works
- Sending: You (Unit 101) want to send a letter. You put it in the "Out" box.
- Swapping: The Clerk takes your letter, crosses out "Unit 101," and writes "500 Security Way" as the return address.
- Recording: The Clerk writes in a logbook: "Letter sent to Amazon from Unit 101."
- Receiving: Amazon sends a package back to "500 Security Way."
- Delivering: The Clerk looks at the logbook, sees it's for the Amazon order, and brings it to Unit 101.
6. Show how they connect
Now that you understand how NAT acts as a "clerk" that hides your internal identity, you can see why this is the primary way we save IPv4 addresses.
7. Give TWO real examples
Example 1 (Basic): When you use a VPN, you are essentially adding a second mailroom. Your local mailroom sends the letter to the VPN's mailroom, which then sends it to the destination. This makes it look like you live in a completely different city!
Example 2 (Cybersecurity): A technique called NAT Slipping is an advanced attack where a hacker tricks your router (the Clerk) into opening a port that should be closed. They do this by sending specially crafted data that makes the Clerk think, "Oh, Unit 101 is expecting this specific weird package from the outside," allowing the hacker to bypass the "front door."
๐ Recap: Public vs. Private & NAT
- The Problem: We ran out of IPv4 addresses (The IP Shortage).
- The Fix: RFC 1918 created Private Ranges (10.x, 172.16.x, 192.168.x) for local use.
- The Bridge: NAT allows your router to translate many Private IPs into one Public IP.
- Security: NAT provides a basic layer of "obscurity" because your internal devices aren't directly reachable from the web.
- Practical uses: Setting up home labs, troubleshooting "Double NAT" issues on gaming consoles, and configuring firewalls.
- Real-world connection: Your ISP (Internet Service Provider) gives you one Public IP, but you likely have 10+ devices at home. NAT is what makes that possible.
๐ Sources & References
- RFC 1631: The original NAT specification.
- RFC 1918: Address Allocation for Private Internets.
- Check Point Software: NAT Security best practices.