Skip to main content

How do you determine the size of a subnet?

The size of a subnet is the number of IP addresses (or hosts) that belong to one subnet. It is determined by the subnet mask (CIDR prefix).

Short and simple: the size of a subnet depends on how many bits in the IP address are allocated to hosts.


The basic principle

For IPv4:

  • total in the address: 32 bits
  • part of them: the network
  • the rest: the hosts

Formula:

Number of addresses = 2^(number of host bits) Number of hosts = 2^(number of host bits) - 2

The - 2 is because:

  • one address is the network address
  • one is the broadcast address

How to determine subnet size step by step

Step 1. Look at the prefix (/24, /26, and so on)

Example:

192.168.1.0/24
  • 32 - 24 = 8 bits for hosts

Step 2. Calculate the number of addresses

2^8 = 256 addresses

Step 3. Calculate the number of hosts

256 - 2 = 254 hosts
PrefixHost bitsTotal addressesUsable hosts
/248256254
/257128126
/2666462
/2753230
/2841614
/29386
/30242

A quick "at a glance" method (useful for an interview)

If the mask ends in:

  • .0 → /24 → 254 hosts
  • .128 → /25 → 126 hosts
  • .192 → /26 → 62 hosts
  • .224 → /27 → 30 hosts
  • .240 → /28 → 14 hosts

What is important to remember

  • the size of a subnet is not the number of devices, but the maximum possible number
  • the network and broadcast addresses are always reserved
  • routers operate on subnets, not on individual IPs

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.