IP Addressing & Subnetting
Master IPv4 address structure, subnet masks, CIDR notation, and how to calculate network ranges.
Learning Objectives
- → Explain IPv4 address structure and octet notation
- → Convert between binary, decimal, and CIDR notation
- → Calculate network address, broadcast, and usable hosts
- → Identify private vs public IP ranges
IPv4 Addressing
An IPv4 address is a 32-bit number written as four decimal octets separated by dots:
192 . 168 . 1 . 10
11000000.10101000.00000001.00001010
Each octet is 8 bits → values 0–255.
Address Classes (Classic)
| Class | First Octet | Default Mask | Networks | Hosts/Network |
|---|---|---|---|---|
| A | 1–126 | /8 (255.0.0.0) | 126 | ~16 million |
| B | 128–191 | /16 (255.255.0.0) | 16,384 | ~65,000 |
| C | 192–223 | /24 (255.255.255.0) | 2 million | 254 |
| D | 224–239 | — | Multicast | — |
| E | 240–255 | — | Reserved | — |
Modern networking uses CIDR instead of classes — classes are legacy knowledge.
Private IP Ranges (RFC 1918)
These addresses are not routable on the internet — used internally:
| Range | CIDR | Usage |
|---|---|---|
| 10.0.0.0 – 10.255.255.255 | /8 | Large enterprises |
| 172.16.0.0 – 172.31.255.255 | /12 | Medium networks |
| 192.168.0.0 – 192.168.255.255 | /16 | Home / small office |
CIDR & Subnet Masks
CIDR (Classless Inter-Domain Routing) uses a /prefix to define how many bits are the network portion:
192.168.1.0/24
↑ 24 network bits → 8 host bits → 2⁸ - 2 = 254 usable hosts
| CIDR | Mask | Hosts |
|---|---|---|
| /24 | 255.255.255.0 | 254 |
| /25 | 255.255.255.128 | 126 |
| /26 | 255.255.255.192 | 62 |
| /27 | 255.255.255.224 | 30 |
| /28 | 255.255.255.240 | 14 |
| /30 | 255.255.255.252 | 2 |
Subnet Calculation — Step by Step
Given: 192.168.10.130/26
- Mask: /26 →
255.255.255.192→ last octet =11000000 - Block size: 256 - 192 = 64
- Subnets start at: 0, 64, 128, 192
- 130 falls in the 128 subnet
- Network address:
192.168.10.128 - Broadcast:
192.168.10.191(128 + 64 - 1) - Usable hosts:
.129–.190= 62 hosts
Special Addresses
| Address | Meaning |
|---|---|
127.0.0.1 |
Loopback (this machine) |
0.0.0.0 |
Unspecified / all interfaces |
255.255.255.255 |
Limited broadcast |
x.x.x.0 |
Network address (not assignable) |
x.x.x.255 (in /24) |
Broadcast (not assignable) |
An IPv4 address is a 32-bit number written as four decimal octets (0–255) separated by dots.
| Octet | Decimal | Binary |
|---|---|---|
| 1st | 192 | 11000000 |
| 2nd | 168 | 10101000 |
| 3rd | 1 | 00000001 |
| 4th | 10 | 00001010 |
How many bits does an IPv4 address contain?
What is the maximum value a single octet can hold?
Private IPs (RFC 1918) are used inside LANs and are NOT routable on the internet. Public IPs are globally unique and reachable from anywhere.
| Range | CIDR | Use Case |
|---|---|---|
| 10.0.0.0 – 10.255.255.255 | /8 | Large enterprises |
| 172.16.0.0 – 172.31.255.255 | /12 | Medium networks |
| 192.168.0.0 – 192.168.255.255 | /16 | Home / small office |
Which IP range is a private address (RFC 1918)?
What does the loopback address 127.0.0.1 represent?
CIDR (Classless Inter-Domain Routing) uses a /prefix to define how many bits are the network portion.
| CIDR | Subnet Mask | Hosts Available | Example Use |
|---|---|---|---|
| /24 | 255.255.255.0 | 254 | Home / small office |
| /25 | 255.255.255.128 | 126 | Split /24 in half |
| /26 | 255.255.255.192 | 62 | Department LAN |
| /27 | 255.255.255.224 | 30 | Small group |
| /30 | 255.255.255.252 | 2 | Point-to-point link |
How many usable hosts does a /26 subnet provide?
What is the subnet mask for a /25 network?
Given any IP + mask, you can find the network address, broadcast, and usable host range in 4 steps.
/26 → 255.255.255.192 — last octet = 11000000
256 − 192 = 64 — subnets start at 0, 64, 128, 192...
130 falls in the 128 block (128 ≤ 130 < 192)
Network: .128 → Broadcast: .191 → Usable: .129 – .190 (62 hosts)
What is the network address of 192.168.5.200/27?
How many bits are the 'host portion' in a /26 network?
💪 Exercises & Challenges
Subnet Calculator Lab
## Task: Manual Subnetting Solve the following subnetting problems **without a calculator** (then verify with `ipcalc`). ### Problem Set **Problem 1**: You have `10.10.20.0/24` and need 4 equal sub
Find the Network Address
A host has IP address `10.20.30.200` with subnet mask `255.255.255.224`. Calculate the **network address** of this subnet. Submit as `FLAG{x.x.x.x}`.