Subnet Cheat Sheet: CIDR to subnet mask, wildcard and host count

Every IPv4 prefix from /0 to /32 and every IPv6 prefix from /0 to /128, with the subnet mask, the wildcard mask, the total addresses and the usable hosts — all computed by the calculator's own engine rather than typed by hand.

  • Every prefix, /0 to /32mask, wildcard, total addresses and usable hosts for all 33 IPv4 prefixes, not just the popular ten.
  • IPv6 as wellall 129 prefixes with exact address counts, including the 18,446,744,073,709,551,616 in a /64.
  • Computed, not typedevery value comes from the calculator's own tested engine, so the /31 and /32 edge cases are right.
  • Filter as you typesearch a prefix, a mask, a wildcard or a host count and the table narrows to it.
  • Wildcards for access liststhe inverse mask beside every prefix, which is what Cisco ACLs and OSPF actually want.
  • Prints on one pagedesigned to be printed and pinned up, or saved as a PDF from your browser.

CIDR reference table

The prefix is the only thing you are given and everything else follows from it. This table is the lookup in both directions: find /26 and read off 255.255.255.192 and 62 hosts, or type a mask you have been handed and find the prefix it means. Every figure comes from the same tested code the calculator runs, so the awkward rows — /31 with its two usable addresses and no broadcast, /32 with one — are right.

Reference
33 of 33 prefixes shown · updates as you type
CIDRSubnet maskWildcard maskTotal addressesUsable hostsNotes
/00.0.0.0255.255.255.2554,294,967,2964,294,967,294The default route. Matches every IPv4 address.
/1128.0.0.0127.255.255.2552,147,483,6482,147,483,646
/2192.0.0.063.255.255.2551,073,741,8241,073,741,822
/3224.0.0.031.255.255.255536,870,912536,870,910
/4240.0.0.015.255.255.255268,435,456268,435,454
/5248.0.0.07.255.255.255134,217,728134,217,726
/6252.0.0.03.255.255.25567,108,86467,108,862
/7254.0.0.01.255.255.25533,554,43233,554,430
/8Class A255.0.0.00.255.255.25516,777,21616,777,214A classful Class A block, and the size of 10.0.0.0/8.
/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,574The size of the 172.16.0.0/12 private range.
/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
/16Class B255.255.0.00.0.255.25565,53665,534A classful Class B block, and the size of 192.168.0.0/16.
/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,094A common allocation to a small site.
/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
/24Class C255.255.255.00.0.0.255256254A classful Class C block. The most common LAN size.
/25255.255.255.1280.0.0.127128126Half a /24 — the first split most people make.
/26255.255.255.1920.0.0.636462A quarter of a /24. Common for small VLANs.
/27255.255.255.2240.0.0.31323030 hosts: the usual size for a modest office segment.
/28255.255.255.2400.0.0.15161414 hosts. Typical for a DMZ or a rack of servers.
/29255.255.255.2480.0.0.7866 hosts. The smallest block that still fits a gateway and a few devices.
/30255.255.255.2520.0.0.3422 hosts: the classic point-to-point link between routers.
/31255.255.255.2540.0.0.1222 hosts with no network or broadcast address (RFC 3021). The modern point-to-point link.
/32255.255.255.2550.0.0.011A single address. A host route, or one entry in an access list.

Also for subnetting

Subnet cheat sheet: every CIDR prefix, its mask and its host count

A subnet cheat sheet exists to answer one question in whichever direction you happen to be going: you have a prefix and need the mask, or you have a mask and need the prefix, or you have a host count and need to know which block fits it. This table answers all three, for every IPv4 prefix from /0 to /32 rather than the popular ten, and for every IPv6 prefix from /0 to /128 as well.

Computed from a tested engine, not typed out

Every other subnet mask cheat sheet on the web is a hand-typed table, which is why they quietly disagree with each other at the edges — whether a /31 has 0 or 2 usable hosts, whether "total" means addresses or hosts, whether the /0 row exists at all. Every figure here is produced by the same code that runs the subnet calculator, covered by the same test suite, and checked against both the values engineers know by heart and the arithmetic identities that must hold for all 33 rows. A typo is not a possible failure mode.

CIDR to subnet mask, and back again

The prefix length counts the leading 1 bits of the mask, so /24 is 24 ones then 8 zeros: 255.255.255.0. Going the other way, count 8 for every 255 and add the partial octet — 128 is 1, 192 is 2, 224 is 3, 240 is 4, 248 is 5, 252 is 6, 254 is 7 — so 255.255.240.0 is 8 + 8 + 4 = /20. You can also just paste the mask into the filter and the table narrows to its row.

Wildcard masks for access lists and OSPF

The wildcard mask sits beside every prefix because it is what Cisco access lists and OSPF network statements actually take, and getting it backwards is one of the most common configuration mistakes there is. It is the subnet mask inverted: a 0 bit means compare this bit, a 1 bit means ignore it, and the two masks always sum to 255 in every octet. If you are working on an access list, the access list matcher will tell you which line permits or denies a given address.

Total addresses versus usable hosts

These are two different numbers and conflating them is how a subnet ends up two addresses too small. The total is the size of the block; the usable count excludes the network address at the bottom and the broadcast address at the top. For every prefix from /0 to /30 the difference is exactly 2. The exceptions are the two everyone gets wrong: a /31 reserves neither address under RFC 3021, so both of its two addresses are usable — which is why it has replaced /30 for router-to-router links — and a /32 is a single host route with one usable address.

IPv6, which most cheat sheets skip

IPv6 prefixes are here too, all 129 of them, with exact counts at full 128-bit precision. IPv6 has no dotted subnet mask — the prefix length is the notation — so those columns are absent rather than left blank. The numbers that matter are small in count and large in value: a /64 is the standard subnet and holds 18,446,744,073,709,551,616 addresses, a /56 is 256 of those and the usual residential allocation, and a /48 is 65,536 of them and the standard allocation to a site. With IPv6 you count subnets, not addresses.

Sizing a subnet from a host count

Add 2 to the number of hosts you need, round up to the next power of two, and that is your block. Fifty hosts becomes 52, rounds to 64, and 64 addresses is a /26. Thirteen hosts becomes 15, rounds to 16, and that is a /28. If you need several different sizes out of one block, the calculator's VLSM splitter does the packing for you, and the subnetting practice tool will drill the arithmetic until you stop needing the table.

Print it, or keep the tab open

The page is laid out to print cleanly on a single sheet — the chrome, the filter and the notes column drop away, leaving the table. Print to PDF for a copy that works offline, or leave the tab open and use the filter, which searches prefixes, masks, wildcards and host counts at once. Every row is also linkable: the /26 row is at #ipv4-26, so you can send someone straight to it.

Subnet mask questions, answered

What is the subnet mask for a /24?

A /24 is 255.255.255.0. It holds 256 addresses, of which 254 are usable for hosts once the network address and the broadcast address are set aside. Its wildcard mask, which is what a Cisco access list or an OSPF network statement wants, is 0.0.0.255.

The /24 is the most common LAN size and the old Class C block. Halving it gives two /25s of 126 hosts each; halving again gives four /26s of 62.

How many hosts are in a /26, /27, /28, /29 and /30?

A /26 has 64 addresses and 62 usable hosts. A /27 has 32 and 30. A /28 has 16 and 14. A /29 has 8 and 6. A /30 has 4 and 2.

The pattern is that each extra prefix bit halves the block, and two addresses in every block are reserved: the first is the network address and the last is the broadcast. So usable hosts is always 2^(32 - prefix) - 2, until you reach /31 and /32, which are special cases.

How do I convert a subnet mask to CIDR notation?

Count the 1 bits in the mask. 255.255.255.0 is 24 ones followed by 8 zeros, so it is a /24. 255.255.255.192 is 26 ones, so it is a /26.

Because each octet is 8 bits, a shortcut is to count 8 for every 255 and then work out the partial octet: 128 adds 1, 192 adds 2, 224 adds 3, 240 adds 4, 248 adds 5, 252 adds 6, 254 adds 7. So 255.255.240.0 is 8 + 8 + 4 = /20. Typing the mask into the filter above finds the row directly.

What is a wildcard mask and how is it different from a subnet mask?

A wildcard mask is the subnet mask inverted. In a subnet mask a 1 bit means the bit belongs to the network; in a wildcard mask a 0 bit means compare this bit and a 1 bit means ignore it. The /24 mask 255.255.255.0 has the wildcard 0.0.0.255, and the two always add to 255 in every octet.

Wildcard masks are what Cisco access lists and OSPF network statements take, which is why they sit beside the subnet mask in this table. They are also more expressive: the compared bits do not have to be contiguous, so 0.0.0.254 matches only the even addresses in a block, which no CIDR prefix can express.

Why does a /31 have 2 usable hosts instead of 0?

Because RFC 3021 says so. A /31 holds two addresses, and by the ordinary rule both would be reserved — one as the network address, one as the broadcast — leaving nothing usable. That would make the prefix pointless, so RFC 3021 defines a /31 on a point-to-point link as having no network or broadcast address at all, leaving both addresses assignable.

This is why /31 is now preferred over /30 for router-to-router links: it does the same job using two addresses instead of four. A /32 is the other special case: a single address, used as a host route or a single access-list entry, and it counts as one usable.

How many addresses are in an IPv6 /64, /56 and /48?

A /64 holds 18,446,744,073,709,551,616 addresses — more than the entire IPv4 internet squared. It is the standard IPv6 subnet size, and SLAAC requires exactly this length, which is why you do not subnet below it.

The prefixes above it are counted in /64s rather than addresses: a /56, the usual residential allocation, is 256 /64 subnets; a /48, the standard allocation to a site, is 65,536 of them. That is the useful mental model for IPv6 — count subnets, not addresses.

What is the difference between total addresses and usable hosts?

Total addresses is the size of the block: 2 raised to the number of host bits. Usable hosts is how many of those you can actually assign to a device.

For every IPv4 prefix from /0 to /30 the difference is exactly 2, because the first address in the block identifies the network itself and the last is the broadcast address for it. Neither can be given to a host. The exceptions are /31, which reserves neither, and /32, which is a single host route. Cheat sheets that show only one number are the reason people size a subnet wrong by two.

Which subnet do I need for 50 hosts?

A /26, which gives 62 usable hosts. The next size down, a /27, gives only 30, so it will not fit.

The general method is to round your host count up to the next power of two after adding 2 for the network and broadcast addresses. 50 + 2 = 52, the next power of two is 64, and 64 addresses is a /26. Type a host count into the filter above and the table narrows to the prefixes that mention it.