WalkthroughDifficulty: Beginner2 min

Reading CIDR Notation: What /24 Means

Count the host bits, raise two to that power, and subtract the two reserved addresses.

CIDR notation (Classless Inter-Domain Routing) writes a block of IP addresses as its first address and a prefix length, such as 192.168.10.0/26. Reading it means finding four things: how many addresses the block holds, its mask, its first and last address, and how many of those can be given to machines. The same four steps work for any prefix.

The goal. Read 192.168.10.0/26 completely.

What you need. The powers of two up to 2 to the power 16, or a willingness to double from 1: 2, 4, 8, 16, 32, 64, 128, 256.

The steps.

  1. Count the host bits. An IPv4 address has 32 bits, so a /26 leaves 32 minus 26, which is 6 host bits.
  2. Count the addresses. Each host bit doubles the count, so 6 host bits give 2 to the power 6, which is 64 addresses.
  3. Find the first and last address. The block starts at its network address and runs for 64 addresses, so it is 192.168.10.0 to 192.168.10.63.
  4. Count the usable hosts. Remove the network address and the broadcast address: 64 minus 2 is 62 hosts, from .1 to .62.
Reading 192.168.10.0/26 in four steps

Input192.168.10.0/26

  1. Host bits

    1. 32 - 26 = 6

    Whatever is not network is host.

  2. Addresses

    1. 6 host bits
    2. 2^6 = 64total

    Every block holds a power of two.

  3. Range

    1. first 192.168.10.0
    2. last 192.168.10.63

    First plus 64, minus one.

  4. Usable hosts

    1. 64 - 2 = 62usable
    2. 192.168.10.1 to 192.168.10.62

    .0 names the network and .63 is broadcast.

Result64 addresses, mask 255.255.255.192, 62 hosts from .1 to .62.

The mask follows from the same count. The last byte of a /26 mask has its top two bits set, 128 plus 64, so the mask is 255.255.255.192.

The same steps on /24. 32 minus 24 leaves 8 host bits, so 256 addresses, from .0 to .255, with 254 usable hosts and a mask of 255.255.255.0.

How you know it worked. Two checks catch most mistakes. The count must be a power of two, and the first address must divide evenly by it in the byte where the boundary falls: a /26 can start at .0, .64, .128 or .192, and never at .50. If someone writes 192.168.10.50/26, they mean the block that contains .50, which starts at .0.

One more check matters in the cloud. Cloud providers reserve a few extra addresses in each subnet, five in AWS, so a /26 there offers 59 hosts. Always count the total from the prefix first, then subtract what your platform reserves.

A shortcut worth learning. Every prefix one shorter doubles the block, and every prefix one longer halves it: /24 is 256, /23 is 512, /22 is 1024, /25 is 128 and /28 is 16.