🧮 Subnetting Mastery
6 分钟阅读
Subnetting Cheat Sheet and Quick Reference
A comprehensive subnetting cheat sheet covering CIDR notation, subnet masks, host counts, and quick-reference tables for IPv4 and IPv6.
IPv4 CIDR Reference Table
| CIDR | Subnet Mask | Wildcard | Addresses | Usable Hosts |
|---|---|---|---|---|
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 (host route) |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 (point-to-point) |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 |
| /21 | 255.255.248.0 | 0.0.7.255 | 2,048 | 2,046 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
Quick Formulas
Total addresses = 2 ^ (32 - prefix)
Usable hosts = 2 ^ (32 - prefix) - 2
Number of subnets = 2 ^ (new_prefix - original_prefix)
Block size = 256 - last_nonzero_mask_octet
Subnet Boundary Quick Check
To find which subnet a host belongs to, divide the host octet by the block size and take the floor:
Host: 192.168.1.173/26
Block size: 256 - 192 = 64
Subnet: 173 / 64 = 2.7 -> floor(2) * 64 = 128
Network: 192.168.1.128/26
Broadcast: 192.168.1.191
Range: .129 -- .190
Powers of 2 Reference
| Power | Value | Common Use |
|---|---|---|
| 2^1 | 2 | /31 point-to-point |
| 2^2 | 4 | /30 WAN link |
| 2^3 | 8 | /29 small segment |
| 2^4 | 16 | /28 server VLAN |
| 2^5 | 32 | /27 department |
| 2^6 | 64 | /26 floor |
| 2^7 | 128 | /25 building |
| 2^8 | 256 | /24 standard LAN |
| 2^16 | 65,536 | /16 site |
| 2^24 | 16,777,216 | /8 enterprise |
Private Address Space Summary
10.0.0.0/8 -> 10.0.0.0 -- 10.255.255.255 (Class A)
172.16.0.0/12 -> 172.16.0.0 -- 172.31.255.255 (Class B range)
192.168.0.0/16 -> 192.168.0.0 -- 192.168.255.255 (Class C range)
Common Mistakes to Avoid
- Forgetting to subtract 2 for network and broadcast addresses (except /31 and /32)
- Misaligning subnet boundaries -- a /27 must start at multiples of 32
- Confusing the wildcard mask with the subnet mask -- wildcard = 255.255.255.255 minus subnet mask
- Assuming /24 always means "256 addresses" without checking the context (it does, but usable hosts are 254)