Cyber Security Basics 📂 Slides · 9 of 11 60 min read

IPv4 Classes, CIDR & Subnetting — Network, Broadcast, VLSM

A 13-slide interactive walkthrough of IPv4 subnetting from scratch — Classes A/B/C/D/E with binary prefixes, CIDR notation, and the AND operation to compute network and broadcast addresses. Includes a full worked example (192.168.1.130 /26 → .128 network, .191 broadcast, 62 usable), splitting a /24 into 4 equal /26 subnets, and a complete VLSM design allocating 67 + 50 + 6 PCs from one /24, with animated diagrams throughout.

🧮

IPv4 Classes, CIDR & Subnetting

IPv4 classes A–E, CIDR notation, AND-operation calculation of network & broadcast addresses, equal-size subnetting, and VLSM for a real lab — 67, 50 & 6 PCs from one /24.
Classes A–E CIDR AND Operation VLSM

Press Next → or use ← → arrow keys

Section 01

IPv4 Classes A · B · C · D · E

Class Leading bits · 32-bit layout (N=network, H=host) Range A 0 7-bit NETWORK 24-bit HOST (16.7 million) 1.0.0.0 – 126.255.255.255 (0.x & 127.x reserved) B 1 0 14-bit NETWORK 16-bit HOST (65 k) 128.0.0.0 – 191.255.255.255 C 1 1 0 21-bit NETWORK 8-bit HOST (254) 192.0.0.0 – 223.255.255.255 D 1 1 1 0 MULTICAST (no host part) 224.0.0.0 – 239.255.255.255 E 1 1 1 1 RESERVED · EXPERIMENTAL 240.0.0.0 – 255.255.255.255 = class-identifier bit(s) = NETWORK bits = HOST bits
🔍
Quick Identification

Look at the first octet: 1–126 → A, 128–191 → B, 192–223 → C, 224–239 → D (multicast), 240–255 → E. (127.x.x.x is loopback, reserved.)

Section 01 · Details

Class-Based Address Space at a Glance

ClassFirst octetDefault maskCIDRNetworksHosts / networkUse
A1 – 126255.0.0.0/812816,777,214Very large orgs
B128 – 191255.255.0.0/1616,38465,534Medium orgs / universities
C192 – 223255.255.255.0/242,097,152254Small LANs
D224 – 239Multicast
E240 – 255Reserved / experimental
⚠️
Why Classes Are Legacy

Classful addressing wastes addresses badly: a Class B for an org needing only 300 hosts wastes ~65,000 addresses. That's exactly why CIDR replaced classes in 1993 — it lets us pick any prefix length that fits the actual need.

Section 01 · Bit Pattern

Identify the Class from the First Byte's Bits

The leading bits of the first octet reveal the class instantly — no lookup table needed.

ClassBit pattern (first byte)Decimal rangeNotes
A 0xxxxxxx 1 – 126 0.x & 127.x are reserved
B 10xxxxxx 128 – 191 medium networks
C 110xxxxx 192 – 223 small LANs
D 1110xxxx 224 – 239 multicast
E 1111xxxx 240 – 255 reserved / experimental
🔍 QUICK BIT-PATTERN CHECK
First byte binary Class 0xxxxxxx → Class A # leading bit is 0 1 0xxxxxx → Class B # leading bits are 1 0 1 1 0xxxxx → Class C # leading bits are 1 1 0 1 1 1 0xxxx → Class D # multicast 1 1 1 1xxxx → Class E # reserved / experimental
⚠️
Important — 127.0.0.1 Is NOT Class A

Even though 127 in binary is 01111111 and starts with a 0, the entire 127.0.0.0/8 block is reserved for loopback — it never reaches a network interface. Similarly, 0.0.0.0/8 is reserved as "this network". Both are excluded from the usable Class A range → Class A really runs 1 – 126, not 1–127.

Section 01 · Class A

Class A — Fixed Bit 0

🎯
Structure

First bit is always 0. The remaining 7 bits of the first octet identify the network. The last 24 bits identify the host.

🧬 BIT LAYOUT (32 bits)
0 N N N N N N N | H H H H H H H H | H H H H H H H H | H H H H H H H H 0 = fixed class bit N = network bit H = host bit
🔢 EXAMPLE — 10.20.30.40
First octet : 10 = 00001010 ^ Fixed bit = 0 ✓ Class A
📏 BINARY RANGE OF FIRST OCTET
Smallest : 00000001 = 1 Largest : 01111110 = 126 USABLE RANGE = 1 – 126 (0 and 127 reserved — next slides) Networks = 2^7 − 2 = 126 Hosts / net = 2^24 − 2 = 16,777,214
Section 01 · Class B

Class B — Fixed Bits 10

🎯
Structure

First 2 bits are always 10. The remaining 14 bits of the first two octets identify the network. The last 16 bits identify the host.

🧬 BIT LAYOUT (32 bits)
1 0 N N N N N N | N N N N N N N N | H H H H H H H H | H H H H H H H H 1 0 = fixed class bits N = network bit H = host bit
🔢 EXAMPLE — 172.16.5.10
First octet : 172 = 10101100 ^^ Fixed bits = 10 ✓ Class B
📏 BINARY RANGE OF FIRST OCTET
Smallest : 10000000 = 128 Largest : 10111111 = 191 RANGE = 128 – 191 Networks = 2^14 = 16,384 Hosts / net = 2^16 − 2 = 65,534
Section 01 · Class C

Class C — Fixed Bits 110

🎯
Structure

First 3 bits are always 110. The remaining 21 bits identify the network. The last 8 bits identify the host.

🧬 BIT LAYOUT (32 bits)
1 1 0 N N N N N | N N N N N N N N | N N N N N N N N | H H H H H H H H 1 1 0 = fixed class bits N = network bit H = host bit
🔢 EXAMPLE — 192.168.1.100
First octet : 192 = 11000000 ^^^ Fixed bits = 110 ✓ Class C
📏 BINARY RANGE OF FIRST OCTET
Smallest : 11000000 = 192 Largest : 11011111 = 223 RANGE = 192 – 223 Networks = 2^21 = 2,097,152 Hosts / net = 2^8 − 2 = 254
Section 01 · Class D

Class D — Fixed Bits 1110 · Multicast

📡
Structure

First 4 bits are always 1110. Used for multicast — one-to-many communication. There is no network/host division; the remaining 28 bits identify a multicast group.

🧬 BIT LAYOUT (32 bits)
1 1 1 0 M M M M | M M M M M M M M | M M M M M M M M | M M M M M M M M 1 1 1 0 = fixed class bits M = multicast group ID
🔢 EXAMPLE — 230.10.20.30
First octet : 230 = 11100110 ^^^^ Fixed bits = 1110 ✓ Class D
📏 BINARY RANGE OF FIRST OCTET
Smallest : 11100000 = 224 Largest : 11101111 = 239 RANGE = 224 – 239 # multicast (video streams, routing updates, mDNS…)
Section 01 · Class E

Class E — Fixed Bits 1111 · Reserved

🔬
Structure

First 4 bits are always 1111. Reserved for experimental / research use only — not assigned to normal hosts on the internet.

🧬 BIT LAYOUT (32 bits)
1 1 1 1 X X X X | X X X X X X X X | X X X X X X X X | X X X X X X X X 1 1 1 1 = fixed class bits X = reserved / experimental
🔢 EXAMPLE — 250.10.20.30
First octet : 250 = 11111010 ^^^^ Fixed bits = 1111 ✓ Class E
📏 BINARY RANGE OF FIRST OCTET
Smallest : 11110000 = 240 Largest : 11111111 = 255 RANGE = 240 – 255 # reserved · experimental only
Section 01 · Memory

Memory Trick — Spot Any Class in Seconds

Fixed BitsClassFirst Octet RangePurpose
0A1 – 126Very large networks
10B128 – 191Medium networks
110C192 – 223Small LANs
1110D224 – 239Multicast
1111E240 – 255Reserved / experimental
🧠 THE PATTERN — EACH CLASS ADDS ONE MORE LEADING 1
A0 B1 0 C1 1 0 D1 1 1 0 E1 1 1 1 # Each successive class adds one more leading 1 before the distinguishing 0 # (E has no trailing 0 — it's the "all-1s" prefix)
30-Second Class Identification

Convert only the first octet to binary. Look at the leading bits: 0… = A · 10… = B · 110… = C · 1110… = D · 1111… = E. Faster than checking decimal ranges once you're used to it.

Section 01 · Exclusions

Why Class A Is 1 – 126, Not 0 – 127

The fixed bit pattern of Class A is 0xxxxxxx, which mathematically covers 0 – 127. But two values in that range are reserved and cannot be used as normal network numbers.

🔍 THE FULL PICTURE
First Octet Binary Class Pattern Usable? Reason ───────────────────────────────────────────────────────────────────── 0 00000000 Class A ❌ No Reserved (0.0.0.0 = "this network") 1 – 126 00000001– 01111110 Class A ✅ Yes Normal Class A networks 127 01111111 Class A ❌ No Loopback (127.0.0.0/8 → 127.0.0.1)
🕳️
0.0.0.0 — Reserved
"this network"
Binary: 00000000.00000000.00000000.00000000
Matches Class A pattern (0xxxxxxx) but reserved as the "unspecified" address. Used by DHCP before an IP is assigned, and as the default route (0.0.0.0/0).
1 – 126 — Usable
normal Class A
126 possible Class A networks. Each supports 16.7 million hosts. Historically handed out only to the biggest orgs (MIT, HP, US DoD, GE, IBM…).
🔁
127.x — Loopback
localhost
Binary: 01111111also matches Class A pattern. The entire 127.0.0.0/8 block is reserved for loopback. 127.0.0.1 always means "my own machine" — packets never leave the interface.
🎯
Key Point

The class is determined only by the fixed leading bits, not by whether the address is usable. 0.0.0.0 and 127.x.x.x both match the Class A pattern 0xxxxxxx — they're just excluded from the usable range because of their reserved purposes.

Section 02

CIDR — Classless Inter-Domain Routing

The Slash Number Is the Number of Network Bits
CIDR notation writes an IP address plus a slash and a number: 192.168.1.0/24. That slash-24 means "the first 24 bits are the network portion" — the remaining 8 bits are the host portion.

No more forced Class A / B / C boundaries. You pick the exact prefix length that matches the number of hosts you need — and stop wasting addresses.
CIDRSubnet maskHost bitsTotal IPsUsable hosts
/24255.255.255.08256254
/25255.255.255.1287128126
/26255.255.255.19266462
/27255.255.255.22453230
/28255.255.255.24041614
/29255.255.255.248386
/30255.255.255.252242
🧮
The Only Formulas You Need

Total addresses in block = 2H   ·   Usable hosts = 2H − 2   (where H = host bits = 32 − prefix)

Section 03 · AND

Find the Network Address — Bitwise AND

To find which network an IP belongs to, perform a bit-by-bit AND of the IP with its subnet mask.

IP address 192 . 168 . 1 . 130 1 0 0 0 0 0 1 0 (last octet only shown — first 24 bits are 11000000.10101000.00000001) AND Subnet mask (/26) 255 . 255 . 255 . 192 1 1 0 0 0 0 0 0 Network address 192 . 168 . 1 . 128 1 0 0 0 0 0 0 0 ← this is the network!
🧠
The AND Rule

1 AND 1 = 1 · 1 AND 0 = 0 · 0 AND anything = 0. Wherever the mask has a 1, the IP bit passes through (network); wherever the mask has a 0, the result is 0 (host bits are wiped).

Section 03 · Broadcast

Find the Broadcast Address — IP OR (NOT Mask)

🧮
The Actual Formula

Broadcast Address = IP Address OR (NOT Subnet Mask)
where NOT inverts every bit ( 0 → 1, 1 → 0 ) and OR gives 1 if either input bit is 1.

Given: IP = 192.168.10.75 · Subnet mask = 255.255.255.192

🧮 STEP 1 — SUBNET MASK IN BINARY
Mask : 255 . 255 . 255 . 192 = 11111111.11111111.11111111.11000000
🔄 STEP 2 — INVERT EVERY BIT (NOT operation)
Mask : 11111111.11111111.11111111.11000000 NOT Mask : 00000000.00000000.00000000.00111111 # flip every 1↔0 = 0 . 0 . 0 . 63
🔢 STEP 3 — IP ADDRESS IN BINARY
IP : 192 . 168 . 10 . 75 = 11000000.10101000.00001010.01001011
➕ STEP 4 — PERFORM THE OR
IP : 11000000.10101000.00001010.01001011 NOT Mask : 00000000.00000000.00000000.00111111 ─────────────────────────────────────── OR Broadcast : 11000000.10101000.00001010.01111111
✅ STEP 5 — CONVERT BACK TO DECIMAL
11000000 = 192 10101000 = 168 00001010 = 10 01111111 = 127 ╔══════════════════════════════════════════╗ ║ BROADCAST ADDRESS = 192.168.10.127 ║ ╚══════════════════════════════════════════╝
🧠
Why the OR Rule Works

1 OR 1 = 1 · 1 OR 0 = 1 · 0 OR 0 = 0. The NOT mask has 1s only in the host positions — so OR-ing sets every host bit to 1 (the definition of a broadcast address) while leaving the network bits of the IP untouched.

Section 03 · Combined

Full Worked Example — Network, Broadcast & Usable

Given: IP = 192.168.1.130, Subnet mask = 255.255.255.192 (/26)

🧮 STEP-BY-STEP CALCULATION
IP (binary) : 11000000.10101000.00000001.10000010 = 192.168.1.130 Mask (binary) : 11111111.11111111.11111111.11000000 = 255.255.255.192 (/26) ───────────────────────────────────────── AND result : 11000000.10101000.00000001.10000000 ← wipe host bits NETWORK ADDRESS = 192.168.1.128 (host bits all 0) Host bits (H) = 32 − 26 = 6 Total addresses = 2^6 = 64 Usable hosts = 2^6 − 2 = 62 First host = 192.168.1.129 Last host = 192.168.1.190 BROADCAST = 192.168.1.191 (host bits all 1: .10111111 = 191)
💡
Shortcut — the "Magic Number" Method

Block size = 256 − mask octet value = 256 − 192 = 64. The subnets in the last octet jump by 64: .0, .64, .128, .192. Since IP .130 falls in the .128.191 block → network is .128, broadcast is .191. Fast mental math ✓

Section 04 · Equal Split

Split 192.168.1.0/24 into 4 Equal Networks

Need 4 equal subnets? Borrow 2 extra bits from the host portion (2² = 4). New prefix = /24 + 2 = /26.

192.168.1.0/24 256 addresses · 254 usable Subnet 1 · /26 192.168.1.0 – .63 bcast: .63 · usable 62 Subnet 2 · /26 192.168.1.64 – .127 bcast: .127 · usable 62 Subnet 3 · /26 192.168.1.128 – .191 bcast: .191 · usable 62 Subnet 4 · /26 192.168.1.192 – .255 bcast: .255 · usable 62 Block size = 256 ÷ 4 = 64 · Jumps: .0 → .64 → .128 → .192 Each subnet: 64 addresses = 62 usable + 1 network + 1 broadcast
Given : 192.168.1.0/24 (need 4 equal subnets) Bits : log₂(4) = 2 extra bits → new prefix = /24 + 2 = /26 Block : 2^(32-26) = 64 addresses each Subnet 1 192.168.1.0/26 range .0 – .63 bcast .63 Subnet 2 192.168.1.64/26 range .64 – .127 bcast .127 Subnet 3 192.168.1.128/26 range .128 – .191 bcast .191 Subnet 4 192.168.1.192/26 range .192 – .255 bcast .255
Section 05

VLSM — Variable Length Subnet Masking

One Size Never Fits All
Your lab has three rooms: 67 PCs, 50 PCs and 6 PCs. If you split a /24 into 4 equal /26 subnets (62 each), the 67-PC room won't fit and the 6-PC room wastes 56 addresses.

VLSM lets each subnet have its own mask length — big rooms get big blocks, small rooms get small blocks, and almost nothing is wasted.
📋 THE VLSM ALGORITHM (5 STEPS)
1
Sort subnet requirements from largest to smallest.
2
For each requirement, compute host bits H such that 2H − 2 ≥ needed hosts.
3
Prefix = 32 − H. Block size = 2H.
4
Assign the block starting at the next free address.
5
Repeat for the next requirement, always continuing from the end of the previous block.
Section 05 · Example

VLSM — 67 PCs + 50 PCs + 6 PCs from 192.168.1.0/24

192.168.1.0/24 · 256 addresses total LAB A · 67 PCs → /25 192.168.1.0/25 (need 128, gets 128, usable 126) range 0 – 127 · bcast .127 LAB B · 50 PCs → /26 192.168.1.128/26 (64, usable 62) 128 – 191 · bcast .191 LAB C · /28 6 PCs 192–207 FREE (48) 192.168.1.208 – .255 available for growth .0 .128 .192 .208 .255 Biggest first — no gaps, no overlaps · 48 addresses reserved for future growth
# Step 1 — sort by size: 67 → 50 → 6 Lab A (67 PCs) need 67+2=69 → 2^H ≥ 69 → H=7 → /25 block 128 192.168.1.0/25 range .0 – .127 bcast .127 Lab B (50 PCs) need 50+2=52 → 2^H ≥ 52 → H=6 → /26 block 64 192.168.1.128/26 range .128 – .191 bcast .191 Lab C (6 PCs) need 6+2= 8 → 2^H ≥ 8 → H=4 → /28 block 16 192.168.1.192/28 range .192 – .207 bcast .207 # Total used: 128 + 64 + 16 = 208 addresses → 48 addresses free for growth ✓
Section 06 · Practice

Practice Problems & Common Traps

✏️
Practice 1
given IP + mask
IP 10.20.30.75, mask 255.255.255.240 (/28). Find network, broadcast, usable range.
Answer: Net 10.20.30.64 · Bcast 10.20.30.79 · Usable .65.78 (14 hosts).
✏️
Practice 2
split into 8 equal
Split 172.16.5.0/24 into 8 equal networks.
Answer: Borrow 3 bits → /27, block = 32. Subnets: .0, .32, .64, .96, .128, .160, .192, .224 each /27.
✏️
Practice 3 — VLSM
100 + 40 + 20 + 2 hosts
From 192.168.10.0/24: 100→/25 (0–127) · 40→/26 (128–191) · 20→/27 (192–223) · 2→/30 (224–227). Free: 228–255.
⚠️
Common Traps

Forgetting the −2 for network & broadcast in host counts. Assigning smaller subnets first (leaves gaps that don't fit the big one). Confusing block size (2H) with usable hosts (2H − 2). /31 and /32 are special — /31 is used only for point-to-point links.

Section 07 · Part 1

Subnetting Golden Rules — 1 to 4

🏆 CORE RULES · 1–4
1
Classes are legacy — CIDR wins. Know Class A/B/C for exams and identifying leading bits, but real networks use CIDR (/x) prefixes for efficiency.
2
Network = IP AND Mask. Bit-by-bit AND wipes the host bits and reveals which network the IP belongs to.
3
Broadcast = Network with all host bits = 1. Always the last address in the subnet. Never assignable to a device.
4
Total = 2H, Usable = 2H − 2. Where H = 32 − prefix. The −2 accounts for network & broadcast.
Section 07 · Part 2

Subnetting Golden Rules — 5 to 8

🏆 CORE RULES · 5–8
5
Equal split → borrow log₂(N) bits. Need 4 subnets from a /24? Borrow 2 bits → /26. Block size = 256 ÷ 4 = 64.
6
VLSM → always allocate biggest first. Sort requirements largest-to-smallest, then assign. Any other order creates gaps that waste addresses.
7
Magic-number shortcut. Block size in the interesting octet = 256 − mask-octet. Subnets jump by that number: .0, .64, .128, .192 for a /26.
8
Leave room to grow. Reserve at least one spare block per site. Re-subnetting a production network mid-project is painful; planning ahead is cheap.
FINAL

You Can Now Design Any IPv4 Network

5IPv4 classes (A–E)
/xCIDR notation
ANDFind network address
2ᴴ−2Usable hosts
VLSMRight-size every subnet
1993CIDR born (RFC 1519)
🎯
The Complete Toolkit

You can now recognise any IPv4 class, translate between CIDR and dotted-decimal masks, compute network & broadcast addresses with the AND operation, split a block into equal subnets, and design a VLSM plan for any real requirement — like 67 + 50 + 6 PCs.

📚
Where To Practise

subnettingpractice.com and subnetting.net for drills. Read RFC 1918 (private ranges) and RFC 4632 (CIDR). Try Packet Tracer or GNS3 to build the lab and watch subnets work live.

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