Cyber Security Basics 📂 Slides · 8 of 11 51 min read

IP Addressing Explained — Public, Private, NAT, Subnet Mask & IPv6

A 16-slide interactive walkthrough of IP addressing from scratch — what an IP is, which OSI layer it lives on, public vs private (RFC 1918) ranges, how to check your own IP with ipconfig / ifconfig / curl, and a fully animated end-to-end diagram of NAT translating your PC's private IP to your router's public IP as packets travel PC → Switch → Router → Internet → Web Server. Covers subnet masks, network & broadcast addresses, and IPv6 fundamentals with an IPv4-vs-IPv6 comparison.

🌐

IP Addressing — Public, Private, NAT, Subnets & IPv6

What an IP address is, which layer it lives on, public vs private, how NAT lets a home network share one public IP, subnet masks, network & broadcast addresses — and where IPv6 fits in.
IPv4 & IPv6 Public vs Private NAT Subnetting

Press Next → or use ← → arrow keys

Section 01

What Is an IP Address?

The Postal Address of Your Device
Every device that talks on a network needs a unique address — just like every house needs a unique postal address so the postman knows where to deliver.

An IP address (Internet Protocol address) is that address. Every packet on the internet has a source IP (where it's from) and a destination IP (where it's going) — routers use these to forward the packet toward its target.
📐
Which Layer? — Layer 3 (Network)

IP lives on Layer 3 of the OSI model (the Network layer), and on the Internet layer of the TCP/IP model. It sits above the physical Wi-Fi / Ethernet layer, and below TCP/UDP which handle reliable delivery and ports.

Section 01 · Usage

What IP Addressing Is Used For

🎯
Unique Identification
who's who
Every phone, laptop, server, printer, IoT sensor gets an IP so the network can tell them apart.
🗺️
Routing
how to get there
Routers read the destination IP on every packet and forward it toward the correct network across the globe.
🚪
Access Control
firewalls
Firewalls allow/block traffic based on source and destination IPs. Whitelists & blacklists work at the IP level.
🌍
Geolocation
GeoIP
Public IPs map to countries/cities — powers Netflix's regional catalogues, fraud detection, and analytics.
📊
Logging & Forensics
who did what
Server logs record the source IP of every request — essential for security investigations and audits.
🎫
Session & QoS
prioritise traffic
QoS rules and rate-limiting use IPs to give voice/video calls priority over bulk downloads.
Section 02

Anatomy of an IPv4 Address — 32 Bits, 4 Octets

192 11000000 Octet 1 8 bits . 168 10101000 Octet 2 8 bits . 1 00000001 Octet 3 8 bits . 10 00001010 Octet 4 8 bits 192.168.1.10 = 8+8+8+8 = 32 bits total ≈ 4.3 billion addresses each octet is 0–255 (2⁸ = 256 values)
🔢
Dotted-Decimal Notation

Humans write IPv4 as 192.168.1.10. Computers see 32 bits: 11000000 10101000 00000001 00001010. Total address space: 2³² ≈ 4.3 billion addresses — which is why we're running out and IPv6 exists.

Section 03

Public vs Private IP Addresses

🌍 Public IP
Globally unique across the entire internet
Assigned by your ISP (or cloud provider)
Reachable from anywhere on the internet
Costs money · registered with RIRs
Examples: 142.250.183.174 (Google), 203.0.113.5
🏠 Private IP
Only unique within your own network
Assigned by your router via DHCP
Not routable on the public internet
Free · defined by RFC 1918
Examples: 192.168.1.10, 10.0.0.5
🤝
They Work Together

Every device inside your home gets a private IP. When those devices talk to the internet, the router uses NAT to make them all share the router's single public IP. More on that in a few slides.

Section 03 · RFC 1918

Private IP Ranges — the RFC 1918 Reserved Blocks

ClassRangeCIDRAddressesWhere you see it
Class A10.0.0.0 – 10.255.255.25510.0.0.0/8~16.7 millionLarge enterprises, cloud VPCs
Class B172.16.0.0 – 172.31.255.255172.16.0.0/12~1 millionMid-size networks, Docker default
Class C192.168.0.0 – 192.168.255.255192.168.0.0/16~65,000Home & small-office routers
🏠
Why Your Home IP Always Starts with 192.168 or 10

These three blocks are reserved for internal use and never appear on the public internet. That's why every household in the world can safely use 192.168.1.1 as their router without a conflict — they're on separate private networks.

🔒
Also Reserved

127.0.0.0/8loopback (your own machine, localhost). 169.254.0.0/16APIPA (auto-assigned when DHCP fails).

Section 04

Check Your Own IP Address

💻 WINDOWS · Command Prompt
C:\Users\Mohit> ipconfig Ethernet adapter Wi-Fi: IPv4 Address. . . . . . . . . . . : 192.168.1.42 ← your private IP Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 ← your router
🐧 LINUX / macOS · Terminal
$ ip addr show # modern Linux $ ifconfig # older Linux / macOS $ ip -br addr # compact one-line output wlan0 UP 192.168.1.42/24 fe80::a4b1:c1ff:fed2:e3f4/64
🌍 CHECK YOUR PUBLIC IP (what the internet sees)
$ curl ifconfig.me 203.0.113.45 $ curl ipinfo.io # adds city, country, ISP # Or just visit these in a browser: https://ifconfig.me https://whatismyipaddress.com
🎯
Two Different IPs — Both Yours

ipconfig shows your private LAN IP (e.g. 192.168.1.42). curl ifconfig.me shows the public IP the world sees — your ISP-assigned router IP. If ten devices in your home run the same command, they'll all see the same public IP.

Section 05

NAT — Network Address Translation

The Office Receptionist
A company has one main phone number (public), and hundreds of employees with internal extensions (private). The receptionist answers the main number and connects incoming calls to the right extension — and outgoing calls appear from the main number.

Your router doing NAT is that receptionist for your home network. Every device inside uses a private IP; NAT translates all their traffic to the one public IP the ISP gave you.
🔀
Why NAT Exists

The world has ~4.3 billion IPv4 addresses but 30+ billion devices. NAT lets an entire home / office / country share a handful of public IPs. It's the reason we haven't run out of IPv4 yet — and why IPv6 wasn't urgent for so long.

1 → manyOne public IP, many devices
PATPort-mapped NAT (most common)
Built-inFirewall side-effect
RFC 3022Standardised 2001
Section 05 · Full Flow

End-to-End Journey — PC → Switch → Router → NAT → Server

◄──── PRIVATE LAN (RFC 1918) ────► ◄──── PUBLIC INTERNET ────► 💻 PC 192.168.1.10 your device 🔀 Switch Layer 2 · MAC forwards frames 🌐 Router + NAT translates src IP LAN: 192.168.1.1 WAN: 203.0.113.5 two interfaces ☁️ Internet 🖥️ Web Server 142.250.183.174 e.g. google.com src: 192.168.1.10 dst: 142.250.183.174 src: 203.0.113.5 ✓ NAT'd dst: 142.250.183.174 src: 142.250.183.174 dst: 203.0.113.5 → NAT 🔥 NAT rewrites source IP as the packet crosses the router — reverse on the way back The web server only ever sees your public IP (203.0.113.5) — never your private one
🎬
The Journey — Watch the Packet Colours

1. PC (192.168.1.10) sends packet to switch   2. Switch (Layer-2) forwards to router by MAC   3. Router does NAT — rewrites the src IP from 192.168.1.10203.0.113.5 and remembers the mapping   4. Packet exits onto the public internet   5. Web server replies to 203.0.113.5   6. Router looks up the mapping and rewrites the destination back to 192.168.1.10.

Section 06

IP + Subnet Mask — Splitting Network from Host

IP address · 32 bits · /24 = first 24 bits are network 1 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 192 168 1 10 NETWORK (24 bits) = 192.168.1.0 HOST (8 bits) = 254 usable IPs Subnet Mask 255.255.255.0 ≡ CIDR /24 ≡ binary 11111111.11111111.11111111.00000000
🎭
What the Mask Actually Does

The subnet mask tells the router which bits of the IP identify the network (blue) and which identify the host (red). /24 means "the first 24 bits are the network" → all devices sharing those bits are on the same LAN.

Section 06 · Special IPs

Network Address & Broadcast Address

In every subnet, two addresses are reserved — they cannot be given to a device.

🏷️
Network Address
first IP · host bits all 0
Names the network itself. In 192.168.1.0/24 → the network address is 192.168.1.0. Routers use it when talking about "the whole network".
📣
Broadcast Address
last IP · host bits all 1
Sends to everyone on the subnet at once. In 192.168.1.0/24192.168.1.255. Used by DHCP, ARP, discovery.
👤
Usable Hosts
everything in between
In a /24: 256 total − 2 reserved = 254 usable IPs (192.168.1.1 through 192.168.1.254).
🔢 QUICK CALCULATION EXAMPLE
# For the network 192.168.1.0/24 (mask 255.255.255.0) Network address : 192.168.1.0 # host bits = 00000000 First usable host : 192.168.1.1 # usually the router Last usable host : 192.168.1.254 Broadcast address : 192.168.1.255 # host bits = 11111111 Total addresses : 256 (2⁸) Usable hosts : 254 (256 − 2 reserved)
🧮
Formula

For a mask with H host bits: total addresses = 2ᴴ, usable hosts = 2ᴴ − 2. /24 → 254 usable, /16 → 65,534 usable, /30 → just 2 usable (perfect for router-to-router links).

Section 07

IPv6 — The Successor We Actually Need

4.3 billion isn't enough
IPv4 has 32 bits → ~4.3 billion addresses. Earth has 30+ billion connected devices today. NAT hid the problem for two decades, but it's a plaster over a broken bone.

IPv6 uses 128 bits — about 340 undecillion addresses. That's roughly 5 × 10²⁸ addresses for every human on Earth. We will never run out again.
🔤
The Format Looks Scary — It Isn't

IPv6 is written as 8 groups of 4 hex digits separated by colons:
2001:0db8:85a3:0000:0000:8a2e:0370:7334
Leading zeros drop, and one run of all-zero groups can be shortened to :::
2001:db8:85a3::8a2e:370:7334

128 bitIPv6 address size
3.4×10³⁸Total IPv6 addresses
No NATEvery device gets a real IP
~45%Global IPv6 adoption 2026
Section 07 · Compare

IPv4 vs IPv6 — Head to Head

PropertyIPv4IPv6
Address size32 bits128 bits
Total addresses~4.3 billion~3.4 × 10³⁸
NotationDotted decimal 192.168.1.10Colon hex 2001:db8::1
NAT required?Almost alwaysNo — every device gets a public IP
Header size20–60 bytes (variable)40 bytes (fixed, faster routing)
BroadcastYes (x.x.x.255)No broadcast — uses multicast instead
Auto-configDHCP requiredBuilt-in SLAAC (self-configures)
SecurityIPsec optionalIPsec designed in from day one
FragmentationRouters & hostsEnd hosts only (faster routers)
Loopback127.0.0.1::1
🚀
Dual-Stack Reality

Modern networks run both — that's called dual-stack. Your laptop probably has both an IPv4 and an IPv6 address right now. Try ipconfig or ip -6 addr to see the IPv6 side.

Section 08 · Part 1

IP Golden Rules — 1 to 4

🏆 KEY TAKEAWAYS · 1–4
1
IP lives on Layer 3. It's the "postal address" of the network layer, above Wi-Fi/Ethernet and below TCP/UDP. Without IP, routing doesn't happen.
2
Know your two IPs. Your private LAN IP (from ipconfig) is what devices in your home see. Your public IP (from curl ifconfig.me) is what the internet sees.
3
Memorise the RFC 1918 ranges. 10/8, 172.16/12, 192.168/16 are your private blocks. Anything else on the LAN is either mis-configured or shouldn't be there.
4
NAT lets many devices share one public IP. Your router rewrites the source IP as packets go out and reverses the mapping on the way back — the whole reason IPv4 hasn't collapsed yet.
Section 08 · Part 2

IP Golden Rules — 5 to 8

🏆 KEY TAKEAWAYS · 5–8
5
Subnet mask splits network from host. /24 means the first 24 bits identify the network, the last 8 identify the device. Master CIDR and subnetting becomes intuitive.
6
Two IPs are always reserved. Network address (host bits all 0) and broadcast address (host bits all 1) — never assign these to a device.
7
Usable hosts = 2ᴴ − 2. /24 → 254, /25 → 126, /30 → 2. Perfect for sizing subnets to the right number of devices.
8
Learn IPv6 now. The future is 128-bit addresses with no NAT and built-in IPsec. Modern systems already run dual-stack — you're already using it.
FINAL

You Now Speak IP Fluently

Layer 3Where IP lives
4.3BTotal IPv4 addresses
3.4×10³⁸Total IPv6 addresses
3RFC 1918 private blocks
2Reserved per subnet
NATWhy IPv4 survived
🎯
The Complete Picture

You understand what an IP is, which layer it lives on, the difference between public and private, how to find both on your device, how NAT lets many devices share one public IP, how subnet masks split networks, why network/broadcast addresses are reserved — and where IPv6 fits in the modern world.

📚
Where To Go Next

Practise VLSM & CIDR subnetting — split a /24 into 4 /26 networks. Read RFC 1918 (private ranges), RFC 3022 (NAT), and RFC 8200 (IPv6). Fire up Wireshark and watch a real packet capture — IP headers make far more sense once you've seen them live.

🌐 End of tutorial · Press to review, or click Restart