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.

Reference·34 commands·Last updated 2026-07-21
cidrNetworkingipSubnets

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/8
A class私有地址(10.0.0.0 - 10.255.255.255)
172.16.0.0/12
B class私有地址(172.16.0.0 - 172.31.255.255)
192.168.0.0/16
C 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/24
Linux 下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