system-design · beginner
IP Addresses — How Machines Find Each Other
Start here
An IP address is a number that helps the network deliver data to the right machine (more precisely, to a network interface on a machine).
When you visit a website:
- DNS turns a name into an IP address.
- Your computer sends packets toward that address.
- Routers forward those packets hop by hop until they arrive.
What you will learn
- Define IP address in plain English.
- Contrast IPv4 and IPv6.
- Explain public vs private addresses.
- Introduce NAT (Network Address Translation) gently.
- Read a simple CIDR block (
/24) without fear. - Connect IP to ports, DNS, and load balancers.
- Work a home Wi-Fi + cloud VPC example.
- Avoid confusing IP identity with user identity.
What you should know first
| Topic | Why |
|---|---|
| DNS | Names map to IPs |
| TCP vs UDP | Transport uses IP underneath |
| Client/server idea | Who connects to whom |
Words you need before we begin
| Term | Plain English |
|---|---|
| IP | Internet Protocol — rules for addressing and routing packets. |
| IP address | Numeric address used by IP. |
| IPv4 | Classic 32-bit addresses (e.g. 192.0.2.10). |
| IPv6 | Newer 128-bit addresses (longer, hex-like). |
| Packet | A chunk of data with headers including source/destination IPs. |
| Router | Device that forwards packets between networks. |
| Public IP | Globally routable on the public internet (with normal rules). |
| Private IP | For internal networks; not globally unique on the public internet. |
| NAT | Rewrites addresses so many private devices share public IPs. |
| CIDR | Compact way to write an address range (e.g. 10.0.0.0/24). |
| Interface | A network attachment point (Ethernet, Wi-Fi, virtual NIC). |
Simple story: street addresses for packages
A package needs a street address to arrive. IP is like that address system for digital packages (packets).
- Public IP ≈ a unique street address the postal service understands worldwide.
- Private IP ≈ apartment numbers inside a building; the outside world may only know the building address.
- NAT ≈ the building receptionist who rewrites apartment mail to use the building’s public entrance.
- DNS ≈ the phone book from “café name” to street address.
The problem IP solves
Without shared addressing:
- Each network would invent private schemes that cannot interconnect.
- The internet could not be a network of networks.
Step-by-step explanation
Step 1 — Addresses identify interfaces, not “souls”
A laptop can have:
- Wi-Fi IP
- Ethernet IP
- VPN IP
Step 2 — IPv4 shape
IPv4 uses 32 bits, usually written as four decimals:
203.0.113.10
There are about 4.3 billion possible values — not enough for every device on Earth to have a unique public IPv4 forever. That scarcity drove private ranges + NAT and the push to IPv6.
Step 3 — Private IPv4 ranges (memorize the idea)
Common private ranges (RFC 1918):
| Range | Typical use |
|---|---|
10.0.0.0/8 | Large private networks, many clouds |
172.16.0.0/12 | Medium private networks |
192.168.0.0/16 | Home routers (192.168.1.x) |
These are not meant to be unique on the global internet. Two companies can both use 10.0.0.5 internally.
Step 4 — Public IPs
Public addresses are assigned through internet registries and cloud providers. Your home router usually has one public IPv4 (or a carrier-grade NAT share). Cloud VMs and load balancers get public IPs when you attach them.
Exposing a database on a public IP without a firewall is a classic incident seed.
Step 5 — NAT in everyday life
Network Address Translation (NAT) lets many devices with private IPs share outbound connectivity via fewer public IPs.
Home example:
- Phone
192.168.1.20opens a connection to a server. - Router rewrites the source to the household public IP + a chosen port.
- Replies come back to the router, which maps them to the phone.
- Many users may appear as one IP (rate limits, abuse bans must be careful).
- Inbound connections to a private device need port forwarding, tunnels, or reverse connections.
- Logs that only store client IP can be coarse behind corporate NAT.
Step 6 — CIDR without tears
CIDR writes a prefix length after /:
10.0.0.0/24≈ 256 addresses (10.0.0.0–10.0.0.255), often ~254 usable hosts./32= single IPv4 address./16= much larger block.
Allowtcp/443from10.0.1.0/24
meaning “HTTPS from that private subnet.”
Step 7 — IPv6 (lightweight)
IPv6 uses 128-bit addresses, written in hex groups:
2001:db8::1 (documentation example style)
Goals include a vastly larger space and simpler end-to-end addressing. Dual-stack systems support both v4 and v6. As a beginner, know:
- AAAA DNS records return IPv6.
- Some networks are IPv6-first.
- Firewalls must cover both families.
Step 8 — IP is not authentication
Anyone can spoof claims in some contexts; production auth uses cryptographic identity (TLS certs, tokens), not “the IP looked friendly.” IP allowlists are a network control, not a full user login system.
Visual mental model
Name to packet delivery
flowchart LR
N[Name example.com] --> D[DNS]
D --> IP[IP address]
IP --> R[Routers]
R --> H[Host interface]
Learning question: Which step fails if DNS is wrong but the server is healthy?
Caption: DNS and IP are different failure domains.
Private network + NAT
flowchart LR
P1[Phone private IP] --> NAT[Home NAT router]
P2[Laptop private IP] --> NAT
NAT --> Pub[Public IP]
Pub --> Net[Internet]
Learning question: What address does the website usually see?
Caption: Often the router’s public IP for many devices.
Complete worked example: cloud web app
Setup
- VPC CIDR
10.0.0.0/16 - Public subnet with load balancer public IP
- Private subnet
10.0.2.0/24with app tasks at10.0.2.10–20 - Database only private
10.0.3.10
Rules of the road
- Users hit public LB IP (from DNS name).
- LB forwards to private app IPs.
- Apps talk to DB over private IP — never need public DB exposure.
- Outbound package installs may use NAT gateway so private tasks reach the internet without inbound exposure.
Failure
A firewall allows 0.0.0.0/0 to DB port “temporarily.” The private IP was not enough protection once a route/public path existed. Network identity needs policy, not hope.
How it works in production
What you configure daily
- Security groups / NACLs / firewall rules by CIDR
- Load balancer target IPs or attachments
- Kubernetes pod IPs (ephemeral) vs Service IPs
- Allowlists for admin access (VPN exit IPs)
Observability
- Flow logs showing source/dest IP and ports
- Deny counts on firewalls
- Client IP headers (
X-Forwarded-For) carefully trusted only from your LB
Ephemeral addresses
In modern clouds, instance IPs come and go. Prefer DNS names, target groups, and service discovery over hard-coded IPs in app config.
Failure modes
| Mode | Symptom | Mitigation |
|---|---|---|
| Hard-coded IP after recreate | Timeouts | Use names/ASGs/target groups |
| Wrong CIDR allow | Too open or too closed | Peer review rules; least privilege |
| Ignoring IPv6 | Half of clients fail | Dual-stack testing |
| Trusting X-Forwarded-For blindly | IP spoof / wrong bans | Only trust hops you control |
| Exhausted NAT ports | Random outbound failures | Scale NAT; reduce connection churn |
Trade-offs
| Choice | Benefit | Cost |
|---|---|---|
| All-private compute | Smaller attack surface | Need NAT/bastion patterns |
| Public IP on every VM | Simple demos | Large attack surface |
| Strict allowlists | Safety | Brittle remote work without VPN |
| IPv6-only | Future-facing | Client compatibility work |
Compare with related concepts
| Term | Difference |
|---|---|
| IP address | Where to deliver packets |
| Port | Which program on that host |
| MAC address | Local link layer identity (not global routing) |
| DNS name | Human-friendly, often stable label for changing IPs |
| Anycast IP | Same address announced from many locations |
Common misunderstandings
- “Private IP means secure.”
- “IP never changes.”
- “localhost is my public identity.”
- “Blocking an IP blocks one human.”
- “IPv6 is optional forever.”
Check your understanding
A private IPv4 address
A guaranteed unique public internet address for one person forever
A DNS domain name
A TLS certificate fingerprint
Sharing public connectivity across many private devices
Encrypting HTTP into HTTPS by itself
Indexing SQL tables
Compressing images
Practice
- Label each as public/private/special:
10.0.2.15,8.8.8.8,127.0.0.1,192.168.0.1. - Write a minimal firewall rule set for app subnet → DB subnet on port 5432.
- Explain why logging only client IP may mis-count users behind CGNAT.
- Describe what breaks if you bake a spot VM’s public IP into a mobile app.
- Sketch DNS + LB + private apps using IPs only as implementation detail.
Revision summary
- IP addresses locate network interfaces for routing.
- IPv4 scarcity led to private ranges and NAT; IPv6 expands space.
- Public vs private is about routability, not automatic security.
- CIDR expresses ranges for policy.
- Prefer names and dynamic registration over hard-coded IPs.
- Do not confuse network allowlists with user authentication.
Glossary
| Term | Definition | Example |
|---|---|---|
| IP address | Network locator number | 203.0.113.5 |
| IPv4 / IPv6 | Address families | 32-bit / 128-bit |
| Private IP | Internal-only addressing | 10.0.2.10 |
| Public IP | Internet-routable (typically) | LB address |
| NAT | Address rewriting at boundary | Home router |
| CIDR | Prefix notation for ranges | 10.0.0.0/24 |
| Router | Forwards between networks | VPC router |
| Interface | Attachment to a network | eth0 |
| DHCP | Dynamic address assignment | Home Wi-Fi lease |
| Localhost | Loopback to self | 127.0.0.1 |
Abbreviations and terminology
| Short | Full |
|---|---|
| IP | Internet Protocol |
| IPv4 / IPv6 | Internet Protocol version 4 / 6 |
| NAT | Network Address Translation |
| CIDR | Classless Inter-Domain Routing |
| VPC | Virtual Private Cloud |
| NIC | Network Interface Card |
| DHCP | Dynamic Host Configuration Protocol |
| DNS | Domain Name System |
| CGNAT | Carrier-Grade NAT |
What to learn next
Primary next lesson: OSI Model — Seven Layers as a Debugging Map
Then revisit load balancing with IP targets and health checks in mind.
Track: Engineering Foundations
Previous: HTTP and HTTPS — How the Web Speaks
Next: Leader Election — Picking One Coordinator
By Shubham Jain