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) - 2The - 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
Examples of the most popular subnets
| Prefix | Host bits | Total addresses | Usable hosts |
|---|---|---|---|
| /24 | 8 | 256 | 254 |
| /25 | 7 | 128 | 126 |
| /26 | 6 | 64 | 62 |
| /27 | 5 | 32 | 30 |
| /28 | 4 | 16 | 14 |
| /29 | 3 | 8 | 6 |
| /30 | 2 | 4 | 2 |
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 readyPremium
A concise answer to help you respond confidently on this topic during an interview.