Understanding IPv4 CIDR Blocks
A CIDR block looks like:
10.0.0.0/16
It has two parts:
- IP address → starting point
- Prefix (/16) → how many bits are fixed
Core Idea (Memorize This First)
- IPv4 = 32 bits total
- CIDR
/N= N bits are fixed (network) - Remaining bits = host bits (free to change)
Total addresses = 2^(32 - N)
IPv4 Structure
An IPv4 address:
10.0.0.0
Breakdown:
10 . 0 . 0 . 0
8 bits 8 bits 8 bits 8 bits
Total = 32 bits
Each block:
- 8 bits = values from 0 to 255
-
Example:
-
0→00000000 -
255→11111111
-
Think in Terms of LOCKED vs FREE
Instead of memorizing formulas, think:
- Locked bits = define the network
- Free bits = generate all possible addresses
Example: 10.0.0.0/16
Step 1: Count free bits
32 - 16 = 16 free bits
Step 2: Calculate total addresses
2^16 = 65,536
Step 3: Visualize
10 . 0 . 0 . 0
[LOCKED] [LOCKED] [FREE] [FREE]
8 bits 8 bits 8 bits 8 bits
- First 2 blocks fixed →
10.0 - Last 2 blocks vary →
0.0to255.255
Range:
10.0.0.0 → 10.0.255.255
How to Read Any CIDR Quickly
Rule:
Move left to right, filling 8 bits per block, until you reach /N.
Example: /10
10.0.0.0/10
10 . 0 . 0 . 0
[8 LOCK] [2 LOCK] [FREE] [FREE]
- 8 bits from first block
- 2 bits from second block
Total locked = 10 bits
Free = 22 bits
Total addresses = 2^22 = 4,194,304
Example: /20
10.0.0.0/20
10 . 0 . 0 . 0
[8 LOCK] [8 LOCK] [4 LOCK] [FREE]
Locked = 20 bits
Free = 12 bits
Total = 2^12 = 4,096
Example: /26
10.0.0.0/26
10 . 0 . 0 . 0
[8 LOCK] [8 LOCK] [8 LOCK] [2 LOCK]
Locked = 26 bits
Free = 6 bits
Total = 2^6 = 64
Example: /30
10.0.0.0/30
10 . 0 . 0 . 0
[8 LOCK] [8 LOCK] [8 LOCK] [6 LOCK]
Free bits = 2
Total = 2^2 = 4
Range:
10.0.0.0 → 10.0.0.3
Shortcut Patterns (High Value)
Instead of recalculating every time:
| CIDR | Free Bits | Total IPs |
|---|---|---|
| /16 | 16 | 65,536 |
| /24 | 8 | 256 |
| /26 | 6 | 64 |
| /30 | 2 | 4 |
Important Practical Note
Not all addresses are usable:
- First IP → network address
- Last IP → broadcast address
Example /30:
10.0.0.0 → network
10.0.0.1 → usable
10.0.0.2 → usable
10.0.0.3 → broadcast
Mental Model (Best Way to Think)
Treat CIDR like a binary lock:
-
/N= how many switches are locked - Remaining switches = combinations
More free bits → bigger network
Fewer free bits → smaller network
One-Line Summary
CIDR is just: how many bits are fixed vs how many bits can vary.
Top comments (0)