IPv4 Classes, CIDR & Subnetting
/24.
Press Next → or use ← → arrow keys
IPv4 Classes A · B · C · D · E
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.)
Class-Based Address Space at a Glance
| Class | First octet | Default mask | CIDR | Networks | Hosts / network | Use |
|---|---|---|---|---|---|---|
| A | 1 – 126 | 255.0.0.0 | /8 | 128 | 16,777,214 | Very large orgs |
| B | 128 – 191 | 255.255.0.0 | /16 | 16,384 | 65,534 | Medium orgs / universities |
| C | 192 – 223 | 255.255.255.0 | /24 | 2,097,152 | 254 | Small LANs |
| D | 224 – 239 | — | — | — | — | Multicast |
| E | 240 – 255 | — | — | — | — | Reserved / experimental |
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.
Identify the Class from the First Byte's Bits
The leading bits of the first octet reveal the class instantly — no lookup table needed.
| Class | Bit pattern (first byte) | Decimal range | Notes |
|---|---|---|---|
| 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 |
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.
Class A — Fixed Bit 0
First bit is always 0. The remaining 7 bits of the first octet identify the network. The last 24 bits identify the host.
Class B — Fixed Bits 10
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.
Class C — Fixed Bits 110
First 3 bits are always 110. The remaining 21 bits identify the network. The last 8 bits identify the host.
Class D — Fixed Bits 1110 · Multicast
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.
Class E — Fixed Bits 1111 · Reserved
First 4 bits are always 1111. Reserved for
experimental / research use only — not assigned to normal hosts on the internet.
Memory Trick — Spot Any Class in Seconds
| Fixed Bits | Class | First Octet Range | Purpose |
|---|---|---|---|
0 | A | 1 – 126 | Very large networks |
10 | B | 128 – 191 | Medium networks |
110 | C | 192 – 223 | Small LANs |
1110 | D | 224 – 239 | Multicast |
1111 | E | 240 – 255 | Reserved / experimental |
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.
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.
00000000.00000000.00000000.00000000Matches 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).
01111111 — also 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.
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.
CIDR — Classless Inter-Domain Routing
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.
| CIDR | Subnet mask | Host bits | Total IPs | Usable hosts |
|---|---|---|---|---|
/24 | 255.255.255.0 | 8 | 256 | 254 |
/25 | 255.255.255.128 | 7 | 128 | 126 |
/26 | 255.255.255.192 | 6 | 64 | 62 |
/27 | 255.255.255.224 | 5 | 32 | 30 |
/28 | 255.255.255.240 | 4 | 16 | 14 |
/29 | 255.255.255.248 | 3 | 8 | 6 |
/30 | 255.255.255.252 | 2 | 4 | 2 |
Total addresses in block = 2H · Usable hosts = 2H − 2 (where H = host bits = 32 − prefix)
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.
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).
Find the Broadcast Address — IP OR (NOT Mask)
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
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.
Full Worked Example — Network, Broadcast & Usable
Given: IP = 192.168.1.130, Subnet mask = 255.255.255.192 (/26)
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 ✓
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.
VLSM — Variable Length Subnet Masking
/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.
VLSM — 67 PCs + 50 PCs + 6 PCs from 192.168.1.0/24
Practice Problems & Common Traps
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).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.192.168.10.0/24: 100→/25 (0–127) · 40→/26 (128–191) · 20→/27 (192–223) · 2→/30 (224–227). Free: 228–255.
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.
Subnetting Golden Rules — 1 to 4
/x) prefixes for efficiency.
Subnetting Golden Rules — 5 to 8
/24? Borrow 2 bits → /26. Block size = 256 ÷ 4 = 64.
.0, .64, .128, .192 for a /26.
You Can Now Design Any IPv4 Network
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.
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