Cheat sheet

Subnetting Cheat Sheet

Exact IPv4 subnetting reference: CIDR prefix to subnet mask to host counts, wildcard masks, the block-size (magic number) method, powers of two, and the private/reserved ranges. Bookmark or print it for fast lookups during CML labs and the CCNA/CCNP exam.

CIDR prefix → mask → hosts

Usable = 2^(32−prefix) − 2 (subtract network + broadcast); /31 = 2 (RFC 3021 P2P), /32 = 1. Block size = 256 − mask value in the interesting octet (3rd octet for /16–/23, 4th octet for /24–/30).

PrefixSubnet maskBlock sizeTotalUsableWildcard
/16255.255.0.025665536655340.0.255.255
/20255.255.240.016409640940.0.15.255
/22255.255.252.04102410220.0.3.255
/23255.255.254.025125100.0.1.255
/24255.255.255.02562562540.0.0.255
/25255.255.255.1281281281260.0.0.127
/26255.255.255.1926464620.0.0.63
/27255.255.255.2243232300.0.0.31
/28255.255.255.2401616140.0.0.15
/29255.255.255.2488860.0.0.7
/30255.255.255.2524420.0.0.3

Powers of two

Each added host bit doubles the count; usable hosts = value − 2.

2^nValue
2^01
2^12
2^24
2^38
2^416
2^532
2^664
2^7128
2^8256
2^9512
2^101024

Block-size (magic number) method

Interesting octet = first octet whose mask is not 255. Block size = 256 − that mask value. Networks start at 0 and count up by the block size; broadcast = next network − 1; hosts sit between network+1 and broadcast−1. Example below: /26 (mask 255.255.255.192, block size 256 − 192 = 64).

Subnet #Network IDFirst hostLast hostBroadcast
1192.168.1.0/26192.168.1.1192.168.1.62192.168.1.63
2192.168.1.64/26192.168.1.65192.168.1.126192.168.1.127
3192.168.1.128/26192.168.1.129192.168.1.190192.168.1.191
4192.168.1.192/26192.168.1.193192.168.1.254192.168.1.255

Private + reserved ranges

RFC 1918 blocks are not routed on the public Internet; the others are special-use.

RangeCIDRUse
10.0.0.0 – 10.255.255.25510.0.0.0/8RFC 1918 private
172.16.0.0 – 172.31.255.255172.16.0.0/12RFC 1918 private
192.168.0.0 – 192.168.255.255192.168.0.0/16RFC 1918 private
127.0.0.0 – 127.255.255.255127.0.0.0/8Loopback (localhost)
169.254.0.0 – 169.254.255.255169.254.0.0/16APIPA / link-local
100.64.0.0 – 100.127.255.255100.64.0.0/10CGNAT (RFC 6598)

Wildcard masks

Wildcard = 255.255.255.255 − subnet mask (bitwise inverse). Used in ACLs and OSPF network statements: 'access-list <100-199> permit ip <src> <wildcard> <dst> <wildcard>' and 'network <ip> <wildcard> area <area-id>'. Shortcuts: 'host <ip>' = 0.0.0.0, 'any' = 0.0.0.0 255.255.255.255.

PrefixSubnet maskWildcard
/8255.0.0.00.255.255.255
/16255.255.0.00.0.255.255
/20255.255.240.00.0.15.255
/22255.255.252.00.0.3.255
/23255.255.254.00.0.1.255
/24255.255.255.00.0.0.255
/25255.255.255.1280.0.0.127
/26255.255.255.1920.0.0.63
/27255.255.255.2240.0.0.31
/28255.255.255.2400.0.0.15
/29255.255.255.2480.0.0.7
/30255.255.255.2520.0.0.3
/32255.255.255.2550.0.0.0

Frequently asked questions

How do I find the number of usable hosts in a subnet?

Count the host bits h = 32 − prefix, then usable = 2^h − 2 (you subtract the network address and the broadcast address). Example: a /27 has 5 host bits, so 2^5 − 2 = 30 usable. Two exceptions: /31 gives 2 usable addresses (RFC 3021 point-to-point links, no broadcast), and /32 is a single host route.

What's the difference between a subnet mask and a wildcard mask?

A subnet mask is a block of contiguous 1s from the left (e.g., 255.255.255.0) that marks the network portion. A wildcard mask is its bitwise inverse (0.0.0.255) where a 0 means 'must match' and a 1 means 'don't care'; it's used in ACLs and OSPF network statements. Compute it as 255.255.255.255 − subnet mask, octet by octet.

How do I use the block-size (magic number) method quickly?

Find the interesting octet (the first mask octet that isn't 255), then block size = 256 − that octet's value. Subnets begin at 0 in that octet and count up by the block size (0, 64, 128, 192 for a /26). Each subnet's broadcast is one less than the next subnet's network, and the usable hosts fall between network+1 and broadcast−1.

Stop memorizing — practice on real Cisco IOS

A cheat sheet gets you unstuck; a graded lab makes it stick. Start with the free sample.