Timedora

2 Network Ranges and Usable Hosts

Learn how IPv4 CIDR prefixes divide network and host bits, how to calculate subnet ranges and host capacity, and when the usual usable-host rule has exceptions.

How prefixes divide IPv4 addresses

An IPv4 address contains 3232 bits. In , an address is followed by a , as in 192.168.10.77/26. The pp identifies the leading network bits; the remaining 32−p32-p bits are and identify addresses within that network. This is equivalent to a subnet mask with pp leading 11 bits.

Calculating network and broadcast addresses

For a pp, set all to 00 to find the , and set all to 11 to find the . The total number of addresses in the block is

232−p2^{32-p}

For conventional subnets from /0 through /30, the is the total address count minus two, because the network and broadcast addresses are reserved.

Finding a subnet with the

To work in decimal, find the octet where the mask stops being 255 or becomes less than 255. The in that octet is 256−mask value256 - \text{mask value}. The network starts at the multiple of that size that contains the given address, and the is the end of that block.

Example: 192.168.10.77/26

A /26 mask is 255.255.255.192. The last-octet is 256−192=64256 - 192 = 64, so the subnet blocks begin at 0, 64, 128, and 192. Since the last octet 77 falls in the block from 64 through 127, the results are:

  • Network: 192.168.10.64

  • Broadcast: 192.168.10.127

  • Usable host range: 192.168.10.65–192.168.10.126

  • Total addresses: 26=642^6 = 64

  • Usable hosts: 64−2=6264 - 2 = 62

The input address 192.168.10.77 is a usable host address in this subnet, not the network or .

and host capacity

The number of is 32−p32-p. For ordinary subnets, the determines the host capacity:

  • /24 has 88 , 256256 total addresses, and 254254 usable hosts.

  • /26 has 66 , 6464 total addresses, and 6262 usable hosts.

  • /30 has 22 , 44 total addresses, and 22 usable hosts.

A larger leaves fewer and creates a smaller address block. For example, /26 contains fewer addresses than /24.

Special cases for /31 and /32

The usual rule of subtracting two addresses has exceptions.

  • A /31 contains two addresses and is used on point-to-point links. Both addresses can be assigned to the link endpoints; neither is treated as the conventional network or directed-.

  • A /32 contains one address and represents a single-address prefix, often used as a .

Checking a subnet calculation

Use these checks to verify a subnet calculation:

  1. Confirm that the prefix is between /0 and /32.

  2. Check that the has all set to 00 and the has all set to 11.

  3. Verify that the given IP address falls between the calculated network and broadcast addresses.

  4. For ordinary subnets, confirm that the usable range excludes those two endpoints. Apply the /31 and /32 exceptions where relevant.