Skip to content

Reference · works without JavaScript

Subnet mask to CIDR cheat sheet.

Every IPv4 prefix from /0 to /32 with its subnet mask, wildcard mask, total addresses and usable host count — a subnet mask to CIDR calculator that needs no JavaScript. Hover any row to copy a value.

IPv4 prefix lengths with masks and host counts
PrefixSubnet maskWildcardAddressesUsable hosts
/04,294,967,2964,294,967,294
/12,147,483,6482,147,483,646
/21,073,741,8241,073,741,822
/3536,870,912536,870,910
/4268,435,456268,435,454
/5134,217,728134,217,726
/667,108,86467,108,862
/733,554,43233,554,430
/816,777,21616,777,214
/98,388,6088,388,606
/104,194,3044,194,302
/112,097,1522,097,150
/121,048,5761,048,574
/13524,288524,286
/14262,144262,142
/15131,072131,070
/1665,53665,534
/1732,76832,766
/1816,38416,382
/198,1928,190
/204,0964,094
/212,0482,046
/221,0241,022
/23512510
/24256254
/25128126
/266462
/273230
/281614
/2986
/3042
/3122
/3211

Common IPv6 prefixes

IPv6 prefixes are not usually chosen to fit a host count — they are chosen to sit on a recognisable boundary. These are the ones that show up in practice.

PrefixAddressesTypical use
/322^96ISP or regional allocation
/402^88Large customer delegation
/482^80One site — 65,536 /64 subnets
/562^72Residential delegation — 256 /64s
/602^6816 /64 subnets
/642^64One subnet — the SLAAC boundary
/1122^16Sometimes used for infrastructure links
/1264Point-to-point, IPv4-style
/1272Point-to-point per RFC 6164
/1281A single host route

Mask octet values

Only nine values can ever appear in a valid IPv4 mask octet. Recognising them is most of what subnetting by hand requires.

0

0 bits

128

1 bit

192

2 bits

224

3 bits

240

4 bits

248

5 bits

252

6 bits

254

7 bits

255

8 bits

Questions people actually ask

How do I convert a subnet mask to a prefix length?

Count the one-bits in the mask. 255.255.255.0 is three full octets of ones plus an empty one, so 8 + 8 + 8 = /24. The only octet values that appear in a valid mask are 0, 128, 192, 224, 240, 248, 252, 254 and 255, contributing 0 through 8 bits respectively.

What is a wildcard mask for?

It is the bitwise inverse of the subnet mask, and Cisco ACLs and OSPF network statements use it instead of a netmask. A /24 has mask 255.255.255.0 and wildcard 0.0.0.255. A zero bit in a wildcard means "must match", a one bit means "ignore".

Why does /31 show 2 usable hosts and not 0?

RFC 3021 permits a /31 on point-to-point links, where there is no need for a broadcast address because there is exactly one other device. Both addresses are assigned. Older equipment may not support it, in which case a /30 with two usable addresses out of four is the fallback.

Which prefix do I need for N hosts?

Find the smallest power of two that is at least N + 2, then subtract its exponent from 32. For 500 hosts you need 512 addresses, which is 2^9, so 32 − 9 = /23. Remember the +2 for the network and broadcast addresses — 254 hosts fit in a /24, but 255 hosts need a /23.

More calculators