Skip to main content

Methodology for calculating subnet masks

1. Why subnet?

  • To divide a large network into several smaller networks (subnetworks).
  • To optimize the use of IP addresses.
  • To isolate services or departments within a network (security, organization).

 

2. The subnet mask

It indicates how many bits are used for the network and host parts.

Two possible notations:

  • Decimal: 255.255.255.0
  • CIDR: /24

 

3. Calculation methodology – step by step

Objective: Find the mask suitable for N machines in a subnetwork

1. Know the number of hosts required (e.g., 50)
2. Add 2 reserved addresses (network + broadcast)
So here: 50 + 2 = 52
3. Find the closest higher power of 2:
2⁵ = 32 not goof
2⁶ = 64 good
4. Deduce the number of bits for the hosts: here 6 bits
5. Calculate the CIDR mask:
32 bits (total) - 6 bits = /26
6. Convert to decimal mask: /26 = 255.255.255.192
7. Check:
Number of usable hosts = 64 - 2 = 62

 

4. Useful correspondence table

CIDR Mask Bits Hosts
/30 255.255.255.252 2 2
/29 255.255.255.248 3 6
/28 255.255.255.240 4 14
/27 255.255.255.224 5 30
/26 255.255.255.192 6 62
/25 255.255.255.128 7 126
/24 255.255.255.0 8 254