Preparing your learning space...
100% through IP Address Classification tutorials
Topics: Subnet Masks | Binary | CIDR | Host Calculation | Network Calculation | Broadcast Address | Practice Examples | Subnetting Exercises
Subnetting = dividing one large network into smaller, manageable pieces.
Four key benefits — less broadcast traffic, better security, logical organization, and efficient IP usage.
| Reason | Why It Matters |
|---|---|
| Reduce traffic | Broadcasts stay within each subnet — less noise |
| Security | Isolate systems per subnet with firewall rules |
| Organization | One subnet per department, floor, or function |
| Efficiency | Give each subnet exactly the IPs it needs — no waste |
A diagram showing the difference between one flat network and three separated subnets.
FLAT (all together):
┌─────────────────────────────────┐
│ 192.168.1.0/24 │
│ 254 devices in one broadcast │
│ domain — everyone sees every │
│ broadcast │
└─────────────────────────────────┘
SUBNETTED (separated):
┌────────────┐ ┌──────────┐ ┌───────────┐
│ .0/26 │ │ .64/26 │ │ .128/26 │
│ Engineering│ │ HR │ │ Sales │
│ 62 devices │ │62 devices│ │ 62 devices│
└────────────┘ └──────────┘ └───────────┘
Broadcasts isolated → less noise, more security
Subnetting is fundamentally binary math. You must be comfortable with the 8-bit octet.
Eight bits with values 128, 64, 32, 16, 8, 4, 2, 1 — the building block of IP addressing.
Bit position: 7 6 5 4 3 2 1 0
Value: 128 64 32 16 8 4 2 1
│ │ │ │ │ │ │ │
1s: 1 1 1 1 1 1 1 1 = 255
1 1 1 1 1 0 0 0 = 248
1 1 0 0 0 0 0 0 = 192
The 8 possible decimal values in a subnet mask octet and their binary equivalents — memorize these.
| Decimal | Binary | # of 1s |
|---|---|---|
| 128 | 10000000 | 1 |
| 192 | 11000000 | 2 |
| 224 | 11100000 | 3 |
| 240 | 11110000 | 4 |
| 248 | 11111000 | 5 |
| 252 | 11111100 | 6 |
| 254 | 11111110 | 7 |
| 255 | 11111111 | 8 |
Memorize these! Every subnet mask octet is one of these values.
A subnet mask uses 1s (network) and 0s (host) to divide an IP; CIDR is shorthand for the number of 1s.
A subnet mask is a 32-bit number that divides an IP into:
The /N in CIDR equals the count of leading 1s in the subnet mask — /26 = 26 ones = 255.255.255.192.
CIDR is shorthand — the number after / = count of leading 1s in the mask:
CIDR: /26 → 26 ones + 6 zeros
Binary: 11111111.11111111.11111111.11000000
Decimal: 255.255.255.192
CIDR values /24 through /30 with their subnet masks and binary last-octet representation.
| CIDR | Mask | Binary (interesting octet) |
|---|---|---|
| /24 | 255.255.255.0 | 00000000 |
| /25 | 255.255.255.128 | 10000000 |
| /26 | 255.255.255.192 | 11000000 |
| /27 | 255.255.255.224 | 11100000 |
| /28 | 255.255.255.240 | 11110000 |
| /29 | 255.255.255.248 | 11111000 |
| /30 | 255.255.255.252 | 11111100 |
Tip: Count the 1s in the last octet and add 24:
Mask: 255.255.255.240 → 4 ones → 24 + 4 = /28
Mask: 255.255.252.0 → 6 ones in 3rd octet → 16 + 6 = /22
The subnet mask determines the split:
/24: NNNNNNNN.NNNNNNNN.NNNNNNNN.HHHHHHHH (24 net, 8 host)
/25: NNNNNNNN.NNNNNNNN.NNNNNNNN.NHHHHHHH (25 net, 7 host)
/26: NNNNNNNN.NNNNNNNN.NNNNNNNN.NNHHHHHH (26 net, 6 host)
/27: NNNNNNNN.NNNNNNNN.NNNNNNNN.NNNHHHHH (27 net, 5 host)
/28: NNNNNNNN.NNNNNNNN.NNNNNNNN.NNNNHHHH (28 net, 4 host)
/29: NNNNNNNN.NNNNNNNN.NNNNNNNN.NNNNNHHH (29 net, 3 host)
/30: NNNNNNNN.NNNNNNNN.NNNNNNNN.NNNNNNHH (30 net, 2 host)
A visual demo showing how mask 255.255.255.192 splits the IP into 26 network bits and 6 host bits.
IP: 192.168.1.45 11000000.10101000.00000001.00101101
Mask: 255.255.255.192 11111111.11111111.11111111.11000000
╔══╗╔══════╗
║Net║║ Host ║
╚══╝╚══════╝
A binary operation (1 AND 1 = 1, else 0) that routers use to determine the network ID from an IP and mask.
Routers use bitwise AND to find which network an IP belongs to:
AND Rule: 1 AND 1 = 1 (everything else = 0)
ANDing IP 192.168.1.45 with mask 255.255.255.192 gives network ID 192.168.1.0 by zeroing the host bits.
IP: 192.168.1.45 11000000.10101000.00000001.00101101
Mask: 255.255.255.192 11111111.11111111.11111111.11000000
AND ──────────────────────────────────────────────────────────
Network: 192.168.1.0 11000000.10101000.00000001.00000000
↑ host bits zeroed
Two devices are on the same subnet if ANDing with the mask gives the same result:
Device A: 192.168.1.45 AND 255.255.255.192 = 192.168.1.0
Device B: 192.168.1.67 AND 255.255.255.192 = 192.168.1.64
↑ Different → They need a router!
Network ID (first, reserved), Broadcast (last, reserved), and Usable Host Range (everything between — assignable to devices).
| Address | What It Is | Example | Assignable? |
|---|---|---|---|
| Network ID | First address — identifies the subnet | 192.168.1.0 | No |
| Usable Host Range | Addresses for devices | .1 – .254 | Yes |
| Broadcast | Last address — reaches all hosts | 192.168.1.255 | No |
192.168.1.0 ← Network ID (reserved)
192.168.1.1 ← First usable host
192.168.1.2
...
192.168.1.254 ← Last usable host
192.168.1.255 ← Broadcast (reserved)
└── 256 TOTAL − 2 RESERVED = 254 USABLE
The fundamental formula for subnetting — block size = 256 minus the mask value in the interesting octet. The block size equals the address count per subnet.
Block Size = 256 − Subnet Mask Value in the Interesting Octet
The interesting octet is where the mask value is not 255 and not 0.
Common block sizes — /26 = 64, /27 = 32, /28 = 16, /29 = 8, /30 = 4 — showing the interesting octet.
| Subnet Mask | Interesting Octet | Block Size |
|---|---|---|
| 255.255.255.0 | 4th (0) | 256 |
| 255.255.255.128 | 4th (128) | 256 − 128 = 128 |
| 255.255.255.192 | 4th (192) | 256 − 192 = 64 |
| 255.255.255.224 | 4th (224) | 256 − 224 = 32 |
| 255.255.255.240 | 4th (240) | 256 − 240 = 16 |
| 255.255.255.248 | 4th (248) | 256 − 248 = 8 |
| 255.255.255.252 | 4th (252) | 256 − 252 = 4 |
| 255.255.252.0 | 3rd (252) | 256 − 252 = 4 (in 3rd octet!) |
| 255.255.0.0 | 3rd (0) | 256 (in 3rd octet) |
The first address of a subnet — found by taking the largest multiple of the block size that is ≤ the IP's octet value.
Step-by-step — find the interesting octet, compute block size, then identify the largest multiple ≤ the target value.
Practical examples finding network IDs for /28, /26, /22, and /20 prefixes.
Find network ID of 192.168.1.45/28:
/28 → 255.255.255.240 → 4th octet interesting
Block = 256 − 240 = 16
Multiples: 0, 16, 32, 48, 64...
45 is between 32 and 48 → largest ≤ 45 = 32
Network ID: 192.168.1.32
More:
| IP/CIDR | Block | Multiples | Network ID |
|---|---|---|---|
| 192.168.1.199/26 | 64 | 128, 192... → 192 | 192.168.1.192 |
| 172.20.45.8/22 | 4 (3rd octet) | 44, 48... → 44 | 172.20.44.0 |
| 10.50.100.200/20 | 16 (2nd octet) | 48, 64... → 48 | 10.48.0.0 |
| 192.168.5.221/28 | 16 | 208, 224... → 208 | 192.168.5.208 |
The last address of a subnet — found by adding (Block Size − 1) to the Network ID in the interesting octet.
Broadcast = (Network ID + Block Size) − 1 — it's always one less than the next network's ID.
Broadcast = (Network ID + Block Size) − 1
Broadcast calculations for /28, /26, /22, and /20 subnets.
| Network ID | Block Size | Next Network | Broadcast |
|---|---|---|---|
| 192.168.1.32/28 | 16 | 192.168.1.48 | 192.168.1.47 |
| 192.168.1.192/26 | 64 | 192.168.1.256 → 192.168.2.0 | 192.168.1.255 |
| 172.20.44.0/22 | 4 (3rd octet) | 172.20.48.0 | 172.20.47.255 |
| 10.48.0.0/20 | 16 (2nd octet) | 10.64.0.0 | 10.63.255.255 |
In binary, the broadcast address has all host bits set to 1.
Network ID: 192.168.1.32 11000000.10101000.00000001.00100000
Set host bits to 1:
Broadcast: 192.168.1.47 11000000.10101000.00000001.00101111
The usable IP addresses — from Network ID + 1 to Broadcast − 1.
First usable = Network ID + 1, Last usable = Broadcast − 1.
First usable = Network ID + 1
Last usable = Broadcast − 1
Host ranges for /28, /26, /22, and /20 subnets.
| Network ID | CIDR | Broadcast | Host Range |
|---|---|---|---|
| 192.168.1.32 | /28 | 192.168.1.47 | .33 – .46 |
| 192.168.1.192 | /26 | 192.168.1.255 | .193 – .254 |
| 172.20.44.0 | /22 | 172.20.47.255 | 44.1 – 47.254 |
| 10.48.0.0 | /20 | 10.63.255.255 | 48.0.1 – 63.255.254 |
A complete step-by-step example — from IP to block size to network ID to broadcast to host range.
Step 1: /27 = 255.255.255.224 → block = 256 − 224 = 32
Step 2: Multiples: 0, 32, 64, 96... 67 → 64
Step 3: Network ID = 192.168.1.64
Step 4: Next network = 192.168.1.96 → Broadcast = 95
Step 5: Range = 192.168.1.65 – 192.168.1.94
✓ Network: 192.168.1.64
✓ Range: 192.168.1.65 – .94
✓ Broadcast: 192.168.1.95
✓ Total: 32 addresses, 30 usable
Usable hosts = 2^(host bits) − 2 — subtract 2 for the Network ID and Broadcast.
Usable hosts = 2^(32 − CIDR) − 2. Each host bit doubles the address count.
Usable hosts = 2^(host bits) − 2
Host bits = 32 − CIDR.
| CIDR | Host Bits | 2^(host bits) | − 2 = Usable |
|---|---|---|---|
| /24 | 8 | 256 | 254 |
| /25 | 7 | 128 | 126 |
| /26 | 6 | 64 | 62 |
| /27 | 5 | 32 | 30 |
| /28 | 4 | 16 | 14 |
| /29 | 3 | 8 | 6 |
| /30 | 2 | 4 | 2 |
Two addresses per subnet are always reserved — the Network ID (first) and the Broadcast (last).
Total addresses = 2^(host bits)
Network ID (−1)
Broadcast (−1)
────────────────────────
Usable = Total − 2
Taking bits from the host portion to create additional network bits — more subnets, fewer hosts per subnet.
Each bit borrowed from host doubles the subnet count but halves the hosts per subnet.
To create more subnets, borrow bits from the host portion:
Original /24:
NNNNNNNN.NNNNNNNN.NNNNNNNN.HHHHHHHH (1 subnet, 254 hosts)
Borrow 3 bits → /27:
NNNNNNNN.NNNNNNNN.NNNNNNNN.SSSHHHHH (8 subnets, 30 hosts each)
│││
└┴┴── subnet bits (borrowed from host)
Subnets created = 2^(borrowed bits). Hosts per subnet = 2^(remaining host bits) − 2.
| What | Formula | Example (borrow 3 from /24) |
|---|---|---|
| Subnets created | 2^(borrowed bits) | 2³ = 8 subnets |
| Usable hosts/subnet | 2^(remaining host bits) − 2 | 2⁵ − 2 = 30 hosts |
A decision table — how many bits to borrow for 2 to 64 subnets and the resulting CIDR and hosts per subnet.
| Need X Subnets | Borrow N Bits | New CIDR | Hosts/Subnet |
|---|---|---|---|
| 2 | 1 | /25 | 126 |
| 4 | 2 | /26 | 62 |
| 8 | 3 | /27 | 30 |
| 16 | 4 | /28 | 14 |
| 32 | 5 | /29 | 6 |
| 64 | 6 | /30 | 2 |
A table listing all subnets with their network IDs, host ranges, and broadcast addresses — network IDs are block size apart.
A /24 split into 4 × /26 subnets — block size 64, 62 hosts each.
Original: /24, need 4 subnets → borrow 2 → /26
Mask: 255.255.255.192
Block: 64
Subnets: 4
Hosts: 62 each
| # | Subnet ID | First Host | Last Host | Broadcast |
|---|---|---|---|---|
| 0 | 192.168.1.0/26 | .1 | .62 | .63 |
| 1 | 192.168.1.64/26 | .65 | .126 | .127 |
| 2 | 192.168.1.128/26 | .129 | .190 | .191 |
| 3 | 192.168.1.192/26 | .193 | .254 | .255 |
Notice: Network IDs are exactly block size (64) apart: 0, 64, 128, 192.
A subnetting technique that gives each subnet exactly the size it needs — eliminates waste by using different prefix lengths.
FLSM allocates the same size to every subnet — wasteful when subnets have different host requirements.
Fixed-length (FLSM) wastes addresses — all subnets get the same size:
FLSM: All /28 → 14 hosts each
Dept A needs 50 hosts → Not enough
Dept B needs 2 hosts → 12 wasted
Each subnet gets exactly the size it needs:
Dept A (50 hosts) → /26 (62 hosts) ✓
Dept B (2 hosts) → /30 (2 hosts) ✓
Three rules — assign largest subnets first, start where previous ends, and choose the smallest prefix that fits.
| Rule | Why |
|---|---|
| Sort by size — largest first | Largest subnets have biggest block size; assign first to avoid fragmentation |
| Start where previous ends | No overlapping ranges |
| Smallest prefix that fits | 25 hosts → /27 (30), not /26 (62) |
Quick reference — given N hosts, use CIDR X which provides Y usable addresses.
| Hosts Needed | Smallest CIDR | Usable | Total IPs |
|---|---|---|---|
| 1–2 | /30 | 2 | 4 |
| 3–6 | /29 | 6 | 8 |
| 7–14 | /28 | 14 | 16 |
| 15–30 | /27 | 30 | 32 |
| 31–62 | /26 | 62 | 64 |
| 63–126 | /25 | 126 | 128 |
| 127–254 | /24 | 254 | 256 |
A /30 subnet provides exactly 2 usable IPs — perfect for directly connecting two routers.
Point-to-point links (routers connected directly) only need 2 addresses — one per router interface.
/30 = 255.255.255.252, block = 4, 2 usable hosts → perfect!
Link R1↔R2: 10.0.0.0/30 .1 (R1) .2 (R2) broadcast .3
Link R2↔R3: 10.0.0.4/30 .5 (R2) .6 (R3) broadcast .7
Link R3↔R4: 10.0.0.8/30 .9 (R3) .10 (R4) broadcast .11
/31 (RFC 3021) is even more efficient — no network/broadcast overhead at all — but requires modern router support.
Split 192.168.1.0/24 into 4 equal subnets using /26 — yields 62 hosts per subnet.
Problem: Split 192.168.1.0/24 into 4 equal subnets.
Borrow 2 → /26, mask 255.255.255.192, block 64, 62 hosts/subnet
Subnet 0: 192.168.1.0/26 (.1 – .62) broadcast .63
Subnet 1: 192.168.1.64/26 (.65 – .126) broadcast .127
Subnet 2: 192.168.1.128/26 (.129 – .190) broadcast .191
Subnet 3: 192.168.1.192/26 (.193 – .254) broadcast .255
✓ 4 subnets, 62 hosts each, all 256 addresses used
VLSM example — 4 departments with different host requirements, assigned from largest to smallest using /26, /27, /28, /29.
Problem: 192.168.10.0/24 → Departments:
| Dept | Hosts | CIDR | Block | Network |
|---|---|---|---|---|
| Engineering | 50 | /26 | 64 | 192.168.10.0/26 (.1 – .62) |
| Marketing | 25 | /27 | 32 | 192.168.10.64/27 (.65 – .94) |
| HR | 10 | /28 | 16 | 192.168.10.96/28 (.97 – .110) |
| Finance | 5 | /29 | 8 | 192.168.10.112/29 (.113 – .118) |
Unused: 192.168.10.120 – .255 (136 addresses).
Compare to FLSM: 4 × /26 = 256 used, 158 wasted. VLSM wastes only 22.
Class B network 172.20.0.0/16 subnetted into /23 subnets — 128 subnets with 510 hosts each.
Problem: 172.20.0.0/16 → subnets with ≥ 500 hosts each.
500 hosts → 2⁹−2 = 510 → needs /23
/16 → /23 = 7 bits borrowed → 2⁷ = 128 subnets
Mask: 255.255.254.0, Block: 2 (3rd octet), Hosts: 510
Subnet 0: 172.20.0.0/23 (.0.1 – .1.254)
Subnet 1: 172.20.2.0/23 (.2.1 – .3.254)
Subnet 2: 172.20.4.0/23 (.4.1 – .5.254)
...
Subnet 127: 172.20.254.0/23 (.254.1 – .255.254)
Connecting 3 routers with /30 links using 10.0.0.0/24 — 4 addresses per link, 2 usable.
Problem: Connect 3 routers in chain using 10.0.0.0/24.
Link R1↔R2: 10.0.0.0/30 .1 (R1) .2 (R2) bcast .3
Link R2↔R3: 10.0.0.4/30 .5 (R2) .6 (R3) bcast .7
Total used: 8 addresses — 2 usable. Much better than /24 per link!
A complete VLSM design using 192.168.0.0/22 — HQ, two branches, VPN tunnels, and future reservation.
Problem: 192.168.0.0/22 → HQ (200 hosts), Branch A (50), Branch B (25), 2 VPN tunnels, future /24 reserved.
Reserve future: 192.168.0.0/24
HQ (/24): 192.168.1.0/24 (1.1 – 1.254)
Branch A (/26): 192.168.2.0/26 (2.1 – 2.62)
Branch B (/27): 192.168.2.64/27 (2.65 – 2.94)
Tunnel A (/30): 192.168.2.96/30 (2.97, 2.98)
Tunnel B (/30): 192.168.2.100/30 (2.101, 2.102)
Remaining: 192.168.2.104 – 192.168.3.255
Test your subnetting skills with 10 problems — basic to advanced, with answers at the end.
Find network ID, broadcast, host range for 192.168.15.87/27.
Split 192.168.50.0/24 into 8 equal subnets. List all 8.
192.168.100.0/24 → IT (45 hosts), Sales (20), R&D (10), Guest (2). Show CIDR, range, unused space.
10.0.0.0/8 → split into /16 subnets. How many? 5th subnet ID? Hosts per /16?
10 point-to-point links using 172.20.0.0/24. Prefix? 10th link ID? Total addresses consumed?
Determine whether pairs of IPs lie on the same subnet given their subnet mask.
| IP 1 | IP 2 | Mask | Same? |
|---|---|---|---|
| 192.168.1.100 | 192.168.1.200 | 255.255.255.0 | |
| 192.168.1.100 | 192.168.2.100 | 255.255.254.0 | |
| 10.0.0.5 | 10.0.1.5 | 255.255.255.0 | |
| 172.16.8.10 | 172.16.12.10 | 255.255.252.0 |
Identify the problem in an overlapping subnet design.
192.168.1.0/24
Dept A: 192.168.1.0/25 (.1 – .126)
Dept B: 192.168.1.64/26 (.65 – .126) ← what's wrong?
Dept C: 192.168.1.128/27 (.129 – .158)
Find the smallest CIDR that supports each host count.
| Hosts | Smallest CIDR |
|---|---|
| 100 | |
| 200 | |
| 400 | |
| 1000 |
172.20.0.0/16 → HQ (1500), DC (500), Branch1 (200), Branch2 (100), 4 P2P links. Design VLSM.
8 rapid-fire questions to test your subnetting speed — answer each in under 10 seconds.
| # | Question | Answer |
|---|---|---|
| 1 | How many /27 subnets in a /24? | |
| 2 | Block size of 255.255.255.248? | |
| 3 | Usable hosts in /29? | |
| 4 | Network ID of 10.0.0.55/28? | |
| 5 | Broadcast of 192.168.1.0/30? | |
| 6 | Bits to borrow for 16 subnets? | |
| 7 | /20 in subnet mask? | |
| 8 | 255.255.254.0 in CIDR? |
Quick reference — the 6-step method, essential CIDR table, and key formulas all in one place.
The complete subnetting procedure — from CIDR to mask to block size to network ID to broadcast to host range.
1. CIDR → subnet mask
2. Find interesting octet (mask ≠ 255, ≠ 0)
3. Block size = 256 − mask value in interesting octet
4. Network ID = largest multiple of block size ≤ IP octet value
5. Broadcast = (Network ID + block size) − 1
6. Host range = Network ID + 1 → Broadcast − 1
The 7 most important CIDR values — memorize these for fast subnetting.
| CIDR | Mask | Block | Usable Hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
All four essential subnetting formulas in one table.
| What | Formula |
|---|---|
| Block size | 256 − mask value |
| Usable hosts | 2^(host bits) − 2 |
| Subnets created | 2^(borrowed bits) |
| Host bits | 32 − CIDR |
Complete solutions to all 10 exercises — expand to check your work.
| Network | Range |
|---|---|
| 192.168.50.0/27 | .1 – .30 |
| .32/27 | .33 – .62 |
| .64/27 | .65 – .94 |
| .96/27 | .97 – .126 |
| .128/27 | .129 – .158 |
| .160/27 | .161 – .190 |
| .192/27 | .193 – .222 |
| .224/27 | .225 – .254 |
IT: /26 → 192.168.100.0/26 (.1–.62)
Sales: /27 → 192.168.100.64/27 (.65–.94)
R&D: /28 → 192.168.100.96/28 (.97–.110)
Guest: /30 → 192.168.100.112/30 (.113–.114)
Remaining: .115 – .255 (141)
256 subnets. 5th = 10.4.0.0/16. 65,534 hosts each.
/30 each. Link 10 = 172.20.0.36/30. Total consumed: 40.
| IP 1 | IP 2 | Mask | Same? |
|---|---|---|---|
| 192.168.1.100 | 192.168.1.200 | 255.255.255.0 | Yes |
| 192.168.1.100 | 192.168.2.100 | 255.255.254.0 | Yes |
| 10.0.0.5 | 10.0.1.5 | 255.255.255.0 | No |
| 172.16.8.10 | 172.16.12.10 | 255.255.252.0 | No (block=4, .8 vs .12) |
Overlap! Dept A (.0/25) covers .1–.126. Dept B (.64/26) covers .65–.126 — entirely inside A. Fix: start Dept B at .128.
100 → /25, 200 → /24, 400 → /23, 1000 → /22.
HQ (1500): /21 → 172.20.0.0/21 (.0.1 – .7.254)
DC (500): /22 → 172.20.8.0/22 (.8.1 – .11.254)
Branch1 (200): /24 → 172.20.12.0/24 (.12.1 – .12.254)
Branch2 (100): /25 → 172.20.13.0/25 (.13.1 – .13.126)
P2P 1–4: /30 → .13.128, .132, .136, .140
Save your progress and earn XP for completing tutorials.
Keep learning
Technology
Cyber Security & Networking
Lesson group
IP Address Classification
Progress
100% complete