CIDR Cheatsheet - Subnet Mask & IP Address Reference
IP-address math is where admins make their costliest slips — a /23 instead of /24 halves your host count silently. This reference maps prefixes to masks and host counts, lists private and special-purpose ranges, and shows how to split/merge subnets. Use it to size a VPC, compose firewall allowlists, and sanity-check a natting table. After reading you compute hosts and ranges without a binary calculator.
CIDR Notation Basics 5
192.168.1.0/24标准 CIDR 写法(IP/前缀length)
IP/前缀前缀表示Network位的位数(0-32)
/24前 24 位为Network位,后 8 位为主机位
主机位数 = 32 - 前缀用于计算 IP 总数
子网掩码由前缀位全 1 推导得出
Subnet Mask Reference 6
/32 = 255.255.255.255 = 1 个 IP单个主机(主机route)
/24 = 255.255.255.0 = 256 个 IP标准 C class子网
/23 = 255.255.254.0 = 512 个 IP超网(merge两个 /24)
/16 = 255.255.0.0 = 65,536 个 IP标准 B class子网
/8 = 255.0.0.0 = 16,777,216 个 IP标准 A class子网
/0 = 0.0.0.0 = 全部 IP默认route(全网)
Common Subnet Sizes 7
/30 = 4 IP(2 可用)点对点链路(最节省)
/29 = 8 IP(6 可用)小型子网
/28 = 16 IP(14 可用)VLAN 常用
/27 = 32 IP(30 可用)中型子网
/26 = 64 IP(62 可用)较大型子网
/25 = 128 IP(126 可用)大型子网
/24 = 256 IP(254 可用)最常见的局域网规模
Private IP Ranges 5
10.0.0.0/8A class私有地址(10.0.0.0 - 10.255.255.255)
172.16.0.0/12B class私有地址(172.16.0.0 - 172.31.255.255)
192.168.0.0/16C class私有地址(192.168.0.0 - 192.168.255.255)
100.64.0.0/10运营商级 NAT(CGN)保留地址
169.254.0.0/16链路本地地址(APIPA 自动Configure)
Special-purpose Addresses 5
0.0.0.0/0默认route(表示所有 IP)
127.0.0.0/8本地回环地址(loopback)
224.0.0.0/4组播地址(multicast)
240.0.0.0/4保留地址(Class E,未分配)
255.255.255.255有限广播地址(本网段所有主机)
Calculation Tools & Examples 6
ipcalc 192.168.1.0/24Linux 下Show子网信息
sipcalc 10.0.0.0/16更verbose的 CIDR 计算工具
ipaddress.ip_network("192.168.1.0/28")Python 标准库 ipaddress 处理 CIDR
网络地址 = IP & 子网掩码按位&运算得到Network地址
广播地址 = 网络地址 | ~掩码主机位全 1 即广播地址
可用 IP = 2^(32-前缀) - 2减去Network地址和广播地址
Tips
- Usable IPs = 2^(32-prefix) - 2 (minus network and broadcast addresses).
- Docker's default bridge is 172.17.0.0/16; Kubernetes Pod CIDR is often 10.244.0.0/16.
- /24 is the most common subnet, good for small LANs.
- ipcalc or sipcalc quickly compute CIDR info from the CLI.
- /31 (2 IPs) is for point-to-point links (RFC 3021) and needs no broadcast address.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us