Skip to main content
CalcChef

Subnet Mask Cheat Sheet

Subnet mask table for every IPv4 prefix from /0 to /32: dotted mask, wildcard, total and usable hosts, with /31 counted as 2 (RFC 3021) and /32 as 1. How it works

Use the Subnet Mask Cheat Sheet

CIDRSubnet MaskWildcardTotal AddressesUsable HostsNetwork BitsCopy
/00.0.0.0255.255.255.2554,294,967,2964,294,967,2940
/1128.0.0.0127.255.255.2552,147,483,6482,147,483,6461
/2192.0.0.063.255.255.2551,073,741,8241,073,741,8222
/3224.0.0.031.255.255.255536,870,912536,870,9103
/4240.0.0.015.255.255.255268,435,456268,435,4544
/5248.0.0.07.255.255.255134,217,728134,217,7265
/6252.0.0.03.255.255.25567,108,86467,108,8626
/7254.0.0.01.255.255.25533,554,43233,554,4307
/8255.0.0.00.255.255.25516,777,21616,777,2148
/9255.128.0.00.127.255.2558,388,6088,388,6069
/10255.192.0.00.63.255.2554,194,3044,194,30210
/11255.224.0.00.31.255.2552,097,1522,097,15011
/12255.240.0.00.15.255.2551,048,5761,048,57412
/13255.248.0.00.7.255.255524,288524,28613
/14255.252.0.00.3.255.255262,144262,14214
/15255.254.0.00.1.255.255131,072131,07015
/16255.255.0.00.0.255.25565,53665,53416
/17255.255.128.00.0.127.25532,76832,76617
/18255.255.192.00.0.63.25516,38416,38218
/19255.255.224.00.0.31.2558,1928,19019
/20255.255.240.00.0.15.2554,0964,09420
/21255.255.248.00.0.7.2552,0482,04621
/22255.255.252.00.0.3.2551,0241,02222
/23255.255.254.00.0.1.25551251023
/24255.255.255.00.0.0.25525625424
/25255.255.255.1280.0.0.12712812625
/26255.255.255.1920.0.0.63646226
/27255.255.255.2240.0.0.31323027
/28255.255.255.2400.0.0.15161428
/29255.255.255.2480.0.0.78629
/30255.255.255.2520.0.0.34230
/31255.255.255.2540.0.0.12231
/32255.255.255.2550.0.0.01132

Which mask fits my hosts?

Rule: pick the smallest block (the longest prefix) whose usable hosts are at least the number you need.

Hosts needed, with the smallest mask that holds them
Hosts needed (up to)Host BitsCIDRSubnet Mask
21/31255.255.255.254
63/29255.255.255.248
144/28255.255.255.240
305/27255.255.255.224
626/26255.255.255.192
1267/25255.255.255.128
2548/24255.255.255.0
5109/23255.255.254.0
1,02210/22255.255.252.0
2,04611/21255.255.248.0
4,09412/20255.255.240.0
8,19013/19255.255.224.0
16,38214/18255.255.192.0
32,76615/17255.255.128.0
65,53416/16255.255.0.0

A /31 (2 hosts) has no network or broadcast address (RFC 3021). Equipment that reserves those two addresses needs a /30 for 2 hosts.

Usable hosts are the total minus the network and broadcast addresses, except /31 (2: both addresses are hosts on a point-to-point link, RFC 3021) and /32 (1: a single host address).

Showing 33 of 33 entries — Values computed from the prefix length for a 32-bit address space

About the Subnet Mask Cheat Sheet

A /24 is the mask 255.255.255.0, with the wildcard 0.0.0.255, 256 addresses and 254 usable hosts. The table covers every IPv4 prefix from /0 to /32 with its dotted mask, wildcard, total addresses and usable hosts. A /31 counts 2 usable hosts (RFC 3021) and a /32 counts 1, because the usual total minus 2 does not fit them. Type a host count under Which mask fits my hosts? and it names the smallest mask: 26 hosts need /27 (255.255.255.224, 30 usable).

The eight mask octet values and the prefixes that end in them

Mask octet1 bits in the octetWildcard octetPrefixes
1281127/1, /9, /17, /25
192263/2, /10, /18, /26
224331/3, /11, /19, /27
240415/4, /12, /20, /28
24857/5, /13, /21, /29
25263/6, /14, /22, /30
25471/7, /15, /23, /31
25580/8, /16, /24, /32

A valid mask is a run of 255s, then one of these values, then 0s. 192 in the fourth octet is /26 (255.255.255.192), in the third /18 (255.255.192.0). Each wildcard octet is 255 minus the mask octet.

Hosts needed and the smallest mask that holds them

Hosts needed (up to)Host bitsCIDRSubnet mask
21/31255.255.255.254
63/29255.255.255.248
144/28255.255.255.240
305/27255.255.255.224
626/26255.255.255.192
1267/25255.255.255.128
2548/24255.255.255.0
5109/23255.255.254.0
1,02210/22255.255.252.0
2,04611/21255.255.248.0
4,09412/20255.255.240.0
8,19013/19255.255.224.0
16,38214/18255.255.192.0
32,76615/17255.255.128.0
65,53416/16255.255.0.0

The rule the tool uses: the longest prefix whose usable hosts are at least the number needed, so 26 hosts need a /27 (30 usable). 2 hosts get a /31 under RFC 3021; equipment that reserves a network and a broadcast address needs a /30 for them.

How to use this tool

  1. Choose All, Common or Classful, or leave All showing.
  2. Type a prefix, a mask, a wildcard or a host count in the search box. Commas and spaces are ignored, so 65536 and 65,536 both find /16.
  3. Press Copy on a row to copy its prefix, mask, wildcard, total and usable hosts as tab-separated text, or Copy table for every row shown, with a header line. Print gives a paper copy without the buttons.

Frequently asked questions

What is the subnet mask for /24, /16 and /8?
/24 is 255.255.255.0 with 254 usable hosts, /16 is 255.255.0.0 with 65,534, and /8 is 255.0.0.0 with 16,777,214. These are also the three classful sizes the Classful filter shows.
How many usable hosts are in a /26 or a /27?
A /26 has 64 addresses and 62 usable hosts; a /27 has 32 addresses and 30 usable hosts. Usable is the total minus the network and broadcast addresses.
Why does a /31 have 2 usable hosts when the formula gives 0?
RFC 3021 says that on a point-to-point link with a 31-bit mask the two addresses must be treated as host addresses, with no network or broadcast address. A /30 spends 4 addresses on two hosts, a /31 spends 2.
What subnet mask do I need for 26 hosts?
A /27, 255.255.255.224: it has 32 addresses and 30 usable hosts, while a /28 holds only 14. Pick the longest prefix whose usable count is at least what you need; the Hosts needed field does this for any number, and the table under it lists the break points from 2 hosts (/31) to 65,534 (/16).
How many hosts does a /32 have?
A /32 is a single address, and the tool shows 1 usable host. That is this tool’s convention: RFC 3021 does not mention /32.
How do I find the prefix for a mask like 255.255.254.0?
Type the mask in the search box. 255.255.254.0 is /23, with 512 addresses and 510 usable hosts. The wildcard 0.0.1.255 is the mask with every bit flipped.

Related Tools

View all tools