Subnet Mask Cheat Sheet: CIDR /8 to /32

This chart maps every CIDR prefix from /8 to /32 to its subnet mask, wildcard mask, total addresses, and usable hosts. Use it when you need the answer fast. The sections below explain how to read it and which sizes are used for what. To work out a specific network, use the subnet calculator.

CIDR to subnet mask chart

PrefixSubnet maskWildcard maskTotal addressesUsable hosts
/8255.0.0.00.255.255.25516,777,21616,777,214
/9255.128.0.00.127.255.2558,388,6088,388,606
/10255.192.0.00.63.255.2554,194,3044,194,302
/11255.224.0.00.31.255.2552,097,1522,097,150
/12255.240.0.00.15.255.2551,048,5761,048,574
/13255.248.0.00.7.255.255524,288524,286
/14255.252.0.00.3.255.255262,144262,142
/15255.254.0.00.1.255.255131,072131,070
/16255.255.0.00.0.255.25565,53665,534
/17255.255.128.00.0.127.25532,76832,766
/18255.255.192.00.0.63.25516,38416,382
/19255.255.224.00.0.31.2558,1928,190
/20255.255.240.00.0.15.2554,0964,094
/21255.255.248.00.0.7.2552,0482,046
/22255.255.252.00.0.3.2551,0241,022
/23255.255.254.00.0.1.255512510
/24255.255.255.00.0.0.255256254
/25255.255.255.1280.0.0.127128126
/26255.255.255.1920.0.0.636462
/27255.255.255.2240.0.0.313230
/28255.255.255.2400.0.0.151614
/29255.255.255.2480.0.0.786
/30255.255.255.2520.0.0.342
/31255.255.255.2540.0.0.122
/32255.255.255.2550.0.0.011

Usable hosts = total addresses − 2 (the network and broadcast addresses). The exceptions are /31, where both addresses are usable on a point-to-point link (RFC 3021), and /32, which is a single host address.

How to read a subnet mask in 30 seconds

Every subnet mask is a run of 1 bits followed by a run of 0 bits, and the prefix length is the number of 1s. Each octet holds 8 bits, so /24 fills exactly three octets (255.255.255.0), while any prefix in between fills part of one octet.

For a mask that cuts through an octet, find the "interesting octet": the one that is neither 255 nor 0. The block size is 256 minus that octet's value. For /27 the mask is 255.255.255.224, the interesting octet is the last one, and 256 − 224 = 32, so subnets start at multiples of 32: .0, .32, .64, .96, .128, .160, .192, and .224. For /20 (255.255.240.0) the interesting octet is the third one and the block size is 16, so subnets in 10.1.0.0 begin at 10.1.0.0, 10.1.16.0, 10.1.32.0, and so on.

To find the subnet an address belongs to, round the interesting octet down to the nearest multiple of the block size. Take 172.16.45.9/20: the third octet is 45, the block size is 16, and the nearest multiple at or below 45 is 32. The network is 172.16.32.0, the next network starts at 172.16.48.0, and the broadcast address is therefore 172.16.47.255.

The binary view

A /26 mask written in binary is 11111111.11111111.11111111.11000000, which is 255.255.255.192. The wildcard mask is the exact inverse, 00000000.00000000.00000000.00111111, which is 0.0.0.63. The six remaining host bits give 26 = 64 addresses and 62 usable hosts.

The addresses you can't use

In an ordinary IPv4 subnet the first address is the network address and the last is the broadcast address, so neither can be assigned to a host. That is where the formula comes from: usable hosts = 2(32 − prefix) − 2. A /24 has 256 addresses and 254 usable; a /29 has 8 addresses and 6 usable.

Two prefixes break the rule. A /31 has two addresses, and under RFC 3021 both can be used on a point-to-point link because there is no need for a broadcast address. Some older equipment does not support this, so /30 is still common. A /32 is one address, used for loopback interfaces, host routes, and firewall rules that match exactly one machine.

Cloud networks reserve more. AWS and Azure each reserve five addresses in every subnet, so a /28 gives 11 usable addresses rather than 14, and Google Cloud reserves four in a subnet's primary range. Check your provider's current documentation before sizing a cloud subnet to an exact host count.

Which prefix length for which job

Common mistakes

Frequently asked questions

What is the subnet mask for /24?

A /24 uses the subnet mask 255.255.255.0 and provides 256 addresses, of which 254 are usable for hosts.

How many hosts are in a /26?

A /26 has 64 addresses in total and 62 usable hosts, because the network and broadcast addresses cannot be assigned to devices. Its subnet mask is 255.255.255.192.

How do I convert a subnet mask to CIDR notation?

Count the 1 bits in the mask. For 255.255.240.0 the first two octets contribute 8 + 8 and the third octet 240 contributes 4 (11110000), so the prefix is /20.

What is the difference between a subnet mask and a wildcard mask?

A wildcard mask is the bitwise inverse of a subnet mask. The subnet mask 255.255.255.0 corresponds to the wildcard mask 0.0.0.255. Subnet masks are used on interfaces and hosts, while wildcard masks are used in Cisco ACLs and routing protocol network statements.

Copied!