Subnet mask cheat sheet

Quick Reference

IPv4 Address
32 bits
Max IPv4 Addresses
4,294,967,296
Classful Defaults
A /8 · B /16 · C /24
Most Common Subnet
/24 (254 hosts)

Key Formulas

These two formulas are the foundation of all subnet calculations.

Formula Expression What It Calculates Example (/26)
Usable hosts 2^(32 − prefix) − 2 How many devices can be assigned IPs 2^(32−26) − 2 = 62
Number of subnets 2^(borrowed bits) How many subnets when splitting a network Splitting /24 → /26 = 2^2 = 4
Block size 256 − mask octet Address increment between subnet boundaries 256 − 192 = 64
Why “− 2” in the host formula? Every subnet reserves two addresses: the first address is the network address (identifies the subnet itself) and the last is the broadcast address (sends to all hosts). Neither can be assigned to devices. Exception: /31 point-to-point links (RFC 3021) use both addresses — no broadcast needed.

Complete IPv4 Subnet Reference Table

All 33 possible IPv4 prefix lengths. Highlighted rows mark classful boundaries (/8, /16, /24).

CIDR Subnet Mask Wildcard Mask Addresses Usable Hosts Class
/32255.255.255.2550.0.0.011Host
/31255.255.255.2540.0.0.122 *P2P
/30255.255.255.2520.0.0.342
/29255.255.255.2480.0.0.786
/28255.255.255.2400.0.0.151614
/27255.255.255.2240.0.0.313230
/26255.255.255.1920.0.0.636462
/25255.255.255.1280.0.0.127128126
/24255.255.255.00.0.0.255256254C
/23255.255.254.00.0.1.255512510
/22255.255.252.00.0.3.2551,0241,022
/21255.255.248.00.0.7.2552,0482,046
/20255.255.240.00.0.15.2554,0964,094
/19255.255.224.00.0.31.2558,1928,190
/18255.255.192.00.0.63.25516,38416,382
/17255.255.128.00.0.127.25532,76832,766
/16255.255.0.00.0.255.25565,53665,534B
/15255.254.0.00.1.255.255131,072131,070
/14255.252.0.00.3.255.255262,144262,142
/13255.248.0.00.7.255.255524,288524,286
/12255.240.0.00.15.255.2551,048,5761,048,574
/11255.224.0.00.31.255.2552,097,1522,097,150
/10255.192.0.00.63.255.2554,194,3044,194,302
/9255.128.0.00.127.255.2558,388,6088,388,606
/8255.0.0.00.255.255.25516,777,21616,777,214A

* /31 uses both addresses for hosts per RFC 3021 (point-to-point links only). Rows highlighted in blue mark classful boundaries.

Subnet Mask in Binary

Every subnet mask is a sequence of contiguous 1-bits (network) followed by 0-bits (host). Understanding the binary is the key to subnetting.

Example: /24 = 255.255.255.0

11111111111111111111111100000000
Network bits (24)
Host bits (8) → 254 usable hosts

Example: /27 = 255.255.255.224

11111111111111111111111111100000
Network bits (27)
Host bits (5) → 30 usable hosts

Octet Binary Values

Each bit position in an octet has a fixed decimal value. This is the basis of all binary-to-decimal conversion.

Bit position76543210
Decimal value1286432168421

Valid Subnet Mask Octets

Only these nine decimal values can appear in a subnet mask octet. Memorize them.

BinaryDecimalNetwork bits in octet
0000000000
100000001281
110000001922
111000002243
111100002404
111110002485
111111002526
111111102547
111111112558

Subnetting a /24 Network

The most common real-world scenario. This table shows every possible split of a /24 network.

PrefixSubnet MaskSubnetsHosts/SubnetBlock SizeExample Ranges (192.168.1.x)
/25255.255.255.1282126128.0–.127, .128–.255
/26255.255.255.19246264.0–.63, .64–.127, .128–.191, .192–.255
/27255.255.255.22483032.0–.31, .32–.63, .64–.95, …
/28255.255.255.240161416.0–.15, .16–.31, .32–.47, …
/29255.255.255.2483268.0–.7, .8–.15, .16–.23, …
/30255.255.255.2526424.0–.3, .4–.7, .8–.11, …
Block size shortcut: Block size = 256 − last non-zero octet of the subnet mask. Subnet boundaries always fall on multiples of the block size. For /26: 256 − 192 = 64, so subnets start at .0, .64, .128, .192.

Private (RFC 1918) Address Ranges

These ranges are not routable on the public internet. Use them freely in internal networks.

RFC 1918 RangeCIDRSubnet MaskTotal AddressesCommon Use
10.0.0.0 – 10.255.255.25510.0.0.0/8255.0.0.016,777,216Enterprise, cloud VPCs
172.16.0.0 – 172.31.255.255172.16.0.0/12255.240.0.01,048,576Mid-size networks
192.168.0.0 – 192.168.255.255192.168.0.0/16255.255.0.065,536Home, small office
Important: Never assign RFC 1918 addresses to internet-facing interfaces. These ranges are reserved for private use only and will not be routed by internet service providers.

FAQ

What is the difference between a subnet mask and CIDR notation?
Both represent the same network boundary in different formats. /24 = 255.255.255.0. CIDR (Classless Inter-Domain Routing) notation is shorter and widely used in routing tables, firewall rules, and cloud configuration. Subnet masks are used in older interfaces and some hardware devices.
How do I calculate the number of usable hosts?
Use the formula: 2^(32 − prefix) − 2. For /24: 2^8 − 2 = 254. For /27: 2^5 − 2 = 30. The −2 accounts for the network address (first) and broadcast address (last) which cannot be assigned to hosts.
What is a wildcard mask?
A wildcard mask is the bitwise inverse of a subnet mask. Where the subnet mask has 1s, the wildcard has 0s, and vice versa. For /24: subnet mask = 255.255.255.0, wildcard = 0.0.0.255. Wildcard masks are used in ACLs on Cisco devices and in OSPF configuration.
What is the block size and why does it matter?
Block size = 256 − last non-zero octet of the subnet mask. It defines the increment between subnets. For /26 (mask 255.255.255.192): block size = 256 − 192 = 64. Subnets start at multiples of 64: .0, .64, .128, .192. This shortcut lets you quickly find subnet boundaries without binary math.
When should I use /30 vs /31 for point-to-point links?
Use /30 for compatibility with older equipment — it provides 2 usable hosts out of 4 addresses. Use /31 on modern equipment for efficiency — both addresses are usable per RFC 3021, saving address space. Most modern routers and switches support /31 links.