subnetting — ipv4

Netmasks and netblock sizes

The relationship between block size, netmask, Cisco "wildcard" bits, CIDR prefix length, and classful designation — for every IPv4 prefix from /16 to /32.

Block size

How many addresses are in the network. The all-zero address refers to the network itself and the all-one address is the broadcast — both unusable — so a given block has two fewer usable addresses than its literal size (except /31 and /32, handled specially below).

Netmask

The dotted-decimal mask applied against an address to define the network. All leading (leftmost) bits in a netmask are ones — e.g. a /22 network pairs with netmask 255.255.252.0.

Cisco wildcard bits

The inverse of the netmask, used in Cisco access-list configuration. It's one less than the block size — the wildcard defines every bit that's allowed to vary within the network.

CIDR prefix

The bit-length of the network part of the address — "/24" means the first 24 bits are fixed. A host route is /32; a full "C-sized" block is /24.

Host bits

The inverse of the prefix — how many bits are free within the network. It's also the exponent of 2 used to calculate block size mathematically.

Classful

A backwards-compatible reference to the archaic Class A/B/C/D/E scheme. Provided only because some people still think in those terms.

PrefixBlock sizeNetmaskWildcard bitsUsable hostsHost bitsClassful
/321255.255.255.2550.0.0.010subnet of Class C
/312255.255.255.2540.0.0.121subnet of Class C
/304255.255.255.2520.0.0.322subnet of Class C
/298255.255.255.2480.0.0.763subnet of Class C
/2816255.255.255.2400.0.0.15144subnet of Class C
/2732255.255.255.2240.0.0.31305subnet of Class C
/2664255.255.255.1920.0.0.63626subnet of Class C
/25128255.255.255.1280.0.0.1271267subnet of Class C
/24256255.255.255.00.0.0.2552548Class C
/23512255.255.254.00.0.1.2555109subnet of Class B
/221,024255.255.252.00.0.3.2551,02210subnet of Class B
/212,048255.255.248.00.0.7.2552,04611subnet of Class B
/204,096255.255.240.00.0.15.2554,09412subnet of Class B
/198,192255.255.224.00.0.31.2558,19013subnet of Class B
/1816,384255.255.192.00.0.63.25516,38214subnet of Class B
/1732,768255.255.128.00.0.127.25532,76615subnet of Class B
/1665,536255.255.0.00.0.255.25565,53416Class B

// thanks to Joe Provo for the original v4 reference this table is based on.