Hi Pythonistas!
Last post we learned how DNS translates names to IP addresses.
But what IS an IP address?
And how does a packet actually travel from your laptop in Kerala
to a server on the other side of the world?
That's what this post is about.
The Internet Is Just Nested Subnets
Here's the mental model most developers never see.
The internet is not a flat network.
It's a tree.
Subnets inside subnets inside subnets.
All the way down.
Internet (IANA)
└── APNIC (Asia Pacific)
└── Kerala Vision 103.21.0.0/16
└── Your area 103.21.4.0/24
└── Your router 103.21.4.51
└── Your home 192.168.1.0/24
└── Your laptop 192.168.1.5
Every level = a subnet.
Every boundary = a router.
You're not just a device on the internet.
You're a node inside a subnet inside a subnet inside a subnet.
What Is an IP Address?
IP address = a unique number assigned to every device on a network.
Like a postal address for your computer.
Two versions exist today.
IPv4
104.21.3.45
Four numbers. Each 0 to 255.
Total possible addresses:
256 × 256 × 256 × 256 = ~4.3 billion
Seemed enough in 1983.
The internet now has more than 4.3 billion devices.
We ran out.
IPv6
2606:4700:3037::ac43:d9b6
Eight groups of hex digits.
Total possible addresses:
340,000,000,000,000,000,000,000,000,000,000,000,000
Every grain of sand on earth could have billions of addresses.
We'll never run out.
Public vs Private IP
Not all IPs are equal.
Public IP
Unique across the entire internet.
Your server on AWS has one.
Anyone on the internet can reach it.
Private IP
Only valid inside a local network.
Your laptop at home has one.
Nobody on the internet can reach it directly.
Reserved private ranges:
10.0.0.0 – 10.255.255.255
172.16.0.0 – 172.31.255.255
192.168.0.0 – 192.168.255.255
These are never assigned as public IPs.
The key rule:
Private IPs → can duplicate across different networks
→ never seen outside their own network
Public IPs → globally unique
→ no duplicates anywhere on earth
Your home has 192.168.1.5.
Your neighbour's home has 192.168.1.5.
Your office has 192.168.1.5.
Same IP. No conflict.
Because they live in separate isolated networks.
They never meet.
NAT - How Private IPs Access the Internet
Your laptop is 192.168.1.5.
You visit google.com.
Google needs to reply.
But 192.168.1.5 is unreachable from the internet.
Your router solves this.
NAT - Network Address Translation.
Outgoing:
192.168.1.5:54231 → router replaces with → 203.0.113.1:54231
Incoming:
203.0.113.1:54231 → router translates back → 192.168.1.5:54231
Router keeps a translation table:
192.168.1.5:54231 → 203.0.113.1:54231
192.168.1.6:61443 → 203.0.113.1:61443
192.168.1.9:49832 → 203.0.113.1:49832
Multiple devices. One public IP.
This is how the world survived IPv4 exhaustion.
CGNAT - Your ISP's Secret
Here's what most people don't know.
Kerala Vision itself does another layer of NAT.
Called CGNAT — Carrier Grade NAT.
Your laptop 192.168.1.5 private
↓ home router NAT
Your router 103.21.4.51 Kerala Vision assigned
↓ Kerala Vision CGNAT
Real public IP 203.x.x.x shared by hundreds of customers
↓
Internet
The IP Google sees when you visit:
not unique to your home.
Shared by potentially hundreds of Kerala Vision customers.
This is why IPv6 matters.
With IPv6 — every device gets a real public IP.
No NAT layers needed.
Direct connection. End to end.
How ISP Identifies Your Router
Good question to ask.
Not just by IP.
Three things together:
Physical port
Your cable plugs into a device in your neighborhood.
Called an OLT (fiber) or DSLAM (DSL).
Port 1 → house down the street
Port 2 → your house ← your router here
Port 3 → neighbour's house
Kerala Vision knows which port = which customer.
Even before your router says anything.
MAC Address
Every network device has a MAC address.
Burned into hardware at manufacturing time.
Your home router: C8:D3:A0:12:45:FF
Format:
6 pairs of hex digits
First 3 pairs → manufacturer
Last 3 pairs → unique device ID
When your router connects:
Kerala Vision sees this MAC.
DHCP assigns IP
Kerala Vision's DHCP server assigns your router an IP:
MAC: C8:D3:A0:12:45:FF → IP: 103.21.4.51
Saved in their system:
Physical port: OLT-KOCHI-04 Port 2
MAC: C8:D3:A0:12:45:FF
IP: 103.21.4.51
Customer: Afsal
This is how they bill you.
This is how they cut your connection if you don't pay:
DHCP: "Don't assign IP to this MAC."
Router connects. Asks for IP. Gets nothing.
No IP = no internet.
Changed your router?
New router = new MAC.
Kerala Vision doesn't recognize it.
Call them. They update their system.
Or — use MAC cloning.
Make your new router fake your old router's MAC.
Kerala Vision thinks nothing changed.
Most router admin panels have this option.
IP vs MAC - The Difference
MAC address → permanent hardware ID
who you are (the device)
used inside one subnet
IP address → logical address, can change
where you are on the network
used for routing across subnets
Think of it like:
MAC → your Aadhaar number (permanent, identifies you)
IP → your home address (can change, identifies location)
ARP - How IP Meets MAC
Inside a subnet - MAC address is used for delivery.
But you only know the IP.
How do you find the MAC?
ARP — Address Resolution Protocol.
Your laptop broadcasts:
"Who has IP 192.168.1.1? Tell me your MAC."
Router replies:
"I have 192.168.1.1. My MAC is C8:D3:A0:12:45:FF."
Your laptop saves this:
192.168.1.1 → C8:D3:A0:12:45:FF
Now sends packet directly to that MAC.
MAC changes at every hop.
This surprises most people.
IP address → stays same end to end
MAC address → changes at every router
Example:
Your laptop → home router
MAC: laptop's MAC → router's MAC
Home router → Kerala Vision router
MAC: home router's MAC → Kerala Vision router's MAC
Kerala Vision router → next router
MAC: Kerala Vision router's MAC → next router's MAC
IP = final destination.
MAC = next stop.
CIDR Notation
You'll see IPs written like this:
192.168.1.0/24
10.0.0.0/8
103.21.0.0/16
That /24 /8 /16 that's CIDR notation.
Number after / = how many bits are the network part.
IPv4 = 32 bits total.
192.168.1.0/24
→ 24 bits network
→ 8 bits for hosts
→ 2⁸ = 256 addresses
→ 254 usable hosts
Common ranges:
/32 → 1 address (single host)
/24 → 256 addresses (254 usable)
/16 → 65,536 addresses
/8 → 16 million addresses
How Routing Works
Your packet travels from Kerala to a US server.
It doesn't teleport.
It hops through many routers.
Each router:
1. Receives packet
2. Reads destination IP
3. Checks routing table
4. Forwards to next router
Like asking for directions:
"How do I get to Mumbai?"
"Go to the next town. Ask again."
Hop by hop. Until destination.
A packet from Kerala to US:
Your router
↓
Kerala Vision router (your area)
↓
Kerala Vision backbone
↓
Undersea cable
↓
US West Coast router
↓
Data center router
↓
Server
Usually under 200ms.
Who Owns Which IPs?
One organization controls all IPs on earth.
IANA - Internet Assigned Numbers Authority.
Hierarchy:
IANA
↓
Regional Internet Registries
APNIC → Asia Pacific (India is here)
ARIN → North America
RIPE → Europe, Middle East
LACNIC → Latin America
AFRINIC → Africa
↓
ISPs / Carriers (like Kerala Vision)
↓
Customers
Kerala Vision goes to APNIC.
Gets a block like 103.21.0.0/16.
65,536 IP addresses.
Shared across all their customers via CGNAT.
Every IP block is registered publicly.
whois 103.21.0.1
Shows:
Organization: Kerala Vision Ltd
Country: IN
Range: 103.21.0.0 - 103.21.255.255
This is how Netflix knows you're in India.
How websites show local language.
How "login from new location" alerts work.
BGP - The Glue of the Internet
How does the rest of the internet know
that 103.21.0.0/16 belongs to Kerala Vision?
BGP - Border Gateway Protocol.
Every carrier announces:
"I own these IP ranges.
Send traffic for these IPs to me."
Kerala Vision tells upstream providers:
"103.21.0.0/16 is mine."
They tell their neighbors.
Who tell their neighbors.
Within minutes - the entire internet knows.
BGP is literally the glue holding the internet together.
BGP has no built-in security.
It runs on trust.
In 2010 - a Chinese ISP accidentally announced:
"We own these 50,000 IP blocks."
Including US government, Dell, CNN.
For 18 minutes - huge chunks of internet traffic
routed through China.
This is called a BGP hijack.
Still an active problem today.
IP in System Design - VPC
This isn't just networking theory.
On AWS every system uses this exact structure.
VPC - Virtual Private Cloud.
Your own private network in the cloud.
Same nested subnet pattern:
VPC: 10.0.0.0/16
Public subnet: 10.0.1.0/24 → load balancers
Private subnet: 10.0.2.0/24 → app servers
Database subnet: 10.0.3.0/24 → PostgreSQL, Redis
Public subnet = reachable from internet.
Private subnet = internal only.
Database subnet = only app servers can reach it.
Standard production architecture:
Internet
↓
Public subnet (load balancer)
↓
Private subnet (app servers)
↓
Database subnet (databases)
We'll go deep on this in Phase 7 - Security.
Two Diagnostic Tools
ping
bash
ping parseltongue.co.in
Is this server reachable? How fast?
traceroute
traceroute parseltongue.co.in
Shows every hop between you and the server:
1 192.168.1.1 1ms your router
2 103.21.4.1 3ms Kerala Vision router
3 103.21.0.1 8ms Kerala Vision backbone
4 ...
n 104.21.3.45 45ms destination
Where exactly is the delay?
Invaluable for debugging slow connections.
Mental Model
IP address → unique address for every device
IPv4 → 4.3 billion addresses (ran out)
IPv6 → 340 undecillion (never running out)
Public IP → reachable from internet, globally unique
Private IP → local network only, can duplicate
NAT → router translates private to public
CGNAT → ISP level NAT, hundreds share one public IP
MAC address → permanent hardware ID, changes every hop
IP address → logical address, stays same end to end
ARP → finds MAC address from IP inside subnet
CIDR → subnet size notation (/24 = 254 hosts)
Routing → hop by hop, each router forwards closer
IANA → controls all IPs on earth
APNIC → Asia Pacific registry (India)
BGP → how carriers announce their IP blocks
BGP hijack → accidentally claiming wrong IP blocks
VPC → your private nested subnet on AWS
ping → test reachability
traceroute → see every hop to destination
What Changed for Me
Before this:
I thought the internet was just... one big network.
After this:
I realized the internet is a tree.
Subnets inside subnets.
Routers at every boundary.
From IANA at the top
all the way down to your laptop.
Every packet hops through that tree -
guided by IP,
delivered by MAC,
translated by NAT -
arriving in milliseconds
from the other side of the world.
What's Coming Next
Now you know the foundation:
Post 1 → HTTP/HTTPS how client and server talk
Post 2A → TCP/UDP how data is delivered
Post 2B → SSH encrypted terminal over TCP
Post 3 → DNS name to IP translation
Post 4 → IP/Subnets how packets are routed
Next
REST vs GraphQL vs gRPC.
You know how data travels.
Now - what shape should that data take?
How should client and server agree on what to ask and what to return?
See you in Post 5.