CalculatorAll.online Logo
CalculatorAll.online
Back to blog
CalculatorAll.onlineDeveloper

How to Calculate Subnet Masks and IP Ranges from CIDR Notation

Master Classless Inter-Domain Routing (CIDR) subnet calculations. Learn how to determine usable host IP addresses, network IDs, and broadcast addresses.

By CalculatorAll Editorial Review Board 3 min read
subnet-calculatorcidr-notationip-subnettingnetwork-engineeringipv4-subnet
Close-up of green network cables plugged into server ports, showcasing technology setup.
Photo byBrett SaylesonPexels

How to Calculate Subnet Masks and IP Ranges from CIDR Notation

In cloud architecture (AWS VPCs, Azure Virtual Networks, Google Cloud) and enterprise networking, CIDR notation (Classless Inter-Domain Routing) is the universal standard for allocating IP address blocks.

Understanding how a CIDR prefix (such as /24 or /16) translates into usable host IP addresses, subnet masks, and network boundaries is a core competency for systems engineers and web developers.

This guide breaks down IPv4 binary math, explains how to determine usable IP addresses, and links to the CalculatorAll Subnet & CIDR Calculator.


What Does the Slash (/) in CIDR Represent?

An IPv4 address consists of 32 binary bits divided into four 8-bit octets (e.g., 192.168.1.0).

The slash notation (/prefix) specifies how many leading bits are allocated to the Network ID, leaving the remaining bits for Host addresses:

Host Bits (h) = 32 - CIDR Prefix

Total IP Addresses = 2^h = 2^(32 - Prefix)

Usable Host IP Addresses = 2^h - 2

(Note: We subtract 2 because the very first IP is the Network Identifier and the very last IP is the Broadcast Address).


Detailed close-up of HTML code on a computer monitor, showcasing web development.
Detailed close-up of HTML code on a computer monitor, showcasing web development. — Photo by Pixabay on Pexels

Step-by-Step Calculation: 192.168.1.0/24

Suppose you are configuring a subnet with the CIDR block 192.168.1.0/24:

  1. Calculate Host Bits: 32 - 24 = 8 bits for hosts.
  2. Calculate Total IPs: 2⁸ = 256 total IP addresses.
  3. Calculate Usable IPs: 256 - 2 = 254 usable host addresses.
  4. Determine the Subnet Mask: The first 24 bits are set to 1 in binary (11111111.11111111.11111111.00000000), which in decimal is 255.255.255.0.
  5. Determine the Address Range:
    • Network ID: 192.168.1.0
    • First Usable Host: 192.168.1.1
    • Last Usable Host: 192.168.1.254
    • Broadcast Address: 192.168.1.255

Close-up of PHP code on a monitor, highlighting development and programming concepts.
Close-up of PHP code on a monitor, highlighting development and programming concepts. — Photo by Pixabay on Pexels

CIDR IPv4 Subnet Cheat Sheet

CIDR PrefixSubnet MaskTotal IPsUsable HostsCommon Use Case
/30255.255.255.25242Point-to-point router links
/29255.255.255.24886Small server DMZ
/28255.255.255.2401614Kubernetes node pods
/27255.255.255.2243230Database subnet cluster
/24255.255.255.0256254Standard office LAN / Web tier
/20255.255.240.04,0964,094Mid-sized cloud VPC
/16255.255.0.065,53665,534Production enterprise VPC

Try the numbers with our calculator

Use your own assumptions instead of relying on a generic example.

Calculate Subnet & CIDR Ranges

Sources and further reading