Guides · IP & network · Updated

Subnetting cheat sheet: CIDR, netmasks and host counts

A subnet is a block of consecutive IP addresses. CIDR notation names it with an address and the number of fixed leading bits, such as 192.0.2.0/24. Each common prefix has a mask, a block size and a number of usable hosts, listed in the cheat sheet.

Calculate a subnet

Enter a network in CIDR form to get its range, mask and host count:

The cheat sheet

PrefixNetmaskAddressesUsable hosts
/8255.0.0.016,777,21616,777,214
/16255.255.0.065,53665,534
/20255.255.240.04,0964,094
/22255.255.252.01,0241,022
/23255.255.254.0512510
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242
/31255.255.255.25422 (point-to-point links, RFC 3021)
/32255.255.255.25511 (a single host)

The formulas

  • Addresses in a block = 2(32 − prefix).
  • Usable hosts = addresses − 2. The first address is the network address and the last is the broadcast address; neither can be given to a device. (A /31 and a /32 are the exceptions.)
  • Block size in the interesting octet = 256 − the mask's value in that octet. A mask of 255.255.255.192 gives 256 − 192 = 64.

Worked example: 192.0.2.130/26

  1. A /26 mask is 255.255.255.192, so the block size is 64 and blocks start at 0, 64, 128 and 192.
  2. 130 falls in the block that starts at 128, so the network address is 192.0.2.128.
  3. The block ends before 192, so the broadcast address is 192.0.2.191.
  4. Usable hosts run from 192.0.2.129 to 192.0.2.190, which is 62 addresses.

Splitting a network

Each extra bit in the prefix halves the block. Splitting 192.0.2.0/24 into four equal parts gives four /26 blocks: 192.0.2.0/26, .64/26, .128/26 and .192/26, each with 62 usable hosts. Pick the smallest block that fits the number of devices with room to grow.

Private ranges

RangeSizeCommon use
10.0.0.0/816.7 millionLarge organisations, cloud networks
172.16.0.0/121 millionMid-size networks, containers
192.168.0.0/1665,536Homes and small offices

These private ranges (RFC 1918) are never routed on the internet. See how to find your IP address to tell your private and public addresses apart.

And IPv6?

The idea is the same, with 128 bits instead of 32. The standard subnet is a /64, so you don't count hosts one by one. A home usually receives a /56 or /60, which holds 256 or 16 networks. Read IPv6 address format for how the addresses are written.

Frequently asked questions

How many hosts are in a /24?

256 addresses, of which 254 are usable. The first is the network address and the last is the broadcast address.

What is CIDR notation?

A way to write a network as an address plus the number of leading bits that are fixed, such as 192.0.2.0/24. The number after the slash replaces the netmask 255.255.255.0.

How do I calculate usable hosts?

2 to the power of (32 minus the prefix length), minus 2. For a /26 that is 64 minus 2, so 62.

What are private IPv4 ranges?

10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. They are not routed on the internet and are reused inside homes and offices.

Does subnetting work the same in IPv6?

The idea is the same but the sizes are not. A /64 is the standard subnet for a network, and a home usually receives a /56 or /60 from its provider.