X Xerobit

IP Address Calculator — Calculate Network and Host Ranges

An IP address calculator finds the network address, broadcast address, and usable host range from an IP and subnet mask or CIDR notation. Here's how the math works and common...

Mian Ali Khalid · · 6 min read
Use the tool
Subnet / CIDR Calculator
Calculate IPv4 subnets — network, broadcast, usable range, wildcard mask. Input CIDR (/24) or dotted mask (255.255.255.0). Binary visualization.
Open Subnet / CIDR Calculator →

An IP address calculator takes an IP address and subnet mask (or CIDR notation) and tells you: the network address, broadcast address, first usable IP, last usable IP, and total host count. These values define the boundaries of a subnet.

Use the Subnet Calculator for instant IP range calculations from any CIDR block or subnet mask.

The four key values

For any subnet, you need to know:

  1. Network address — the first IP in the range (host bits all 0)
  2. Broadcast address — the last IP in the range (host bits all 1)
  3. First usable host — network address + 1
  4. Last usable host — broadcast address - 1

For 192.168.1.0/24:

  • Network: 192.168.1.0
  • Broadcast: 192.168.1.255
  • First host: 192.168.1.1
  • Last host: 192.168.1.254
  • Usable hosts: 254

The calculation step by step

Input: 10.0.5.67/22

Step 1: Convert CIDR to subnet mask

/22 → 22 ones followed by 10 zeros
11111111.11111111.11111100.00000000
= 255.255.252.0

Step 2: Find the network address (AND operation)

IP:   10.0.5.67   = 00001010.00000000.00000101.01000011
Mask: 255.255.252.0 = 11111111.11111111.11111100.00000000
AND:  10.0.4.0    = 00001010.00000000.00000100.00000000

Network address: 10.0.4.0

Step 3: Find the broadcast address (OR with inverted mask)

Network: 10.0.4.0    = 00001010.00000000.00000100.00000000
Inv mask: 0.0.3.255  = 00000000.00000000.00000011.11111111
OR:  10.0.7.255      = 00001010.00000000.00000111.11111111

Broadcast: 10.0.7.255

Step 4: Usable range

First host: 10.0.4.1
Last host:  10.0.7.254
Usable hosts: 2^10 - 2 = 1,022

10.0.5.67 is inside this range, confirming it’s a valid host in the 10.0.4.0/22 subnet.

Checking if an IP is in a subnet

import ipaddress

# Check if IP is in a network:
network = ipaddress.ip_network('10.0.4.0/22')
ip = ipaddress.ip_address('10.0.5.67')

print(ip in network)  # True
print(ipaddress.ip_address('10.0.8.1') in network)  # False

# Full network info:
print(network.network_address)   # 10.0.4.0
print(network.broadcast_address) # 10.0.7.255
print(network.netmask)           # 255.255.252.0
print(network.num_addresses)     # 1024
print(list(network.hosts())[0])  # 10.0.4.1  (first usable)
print(list(network.hosts())[-1]) # 10.0.7.254 (last usable)
// Using ip-address library:
const { Address4 } = require('ip-address');

const network = new Address4('10.0.4.0/22');
const ip = new Address4('10.0.5.67');

console.log(network.isInSubnet(ip));     // True (ip in network)
console.log(network.startAddress().address); // '10.0.4.0'
console.log(network.endAddress().address);   // '10.0.7.255'

Common subnets and their ranges

CIDRFirst IPLast IPHosts
10.0.0.0/810.0.0.110.255.255.25416,777,214
10.0.0.0/1610.0.0.110.0.255.25465,534
10.0.0.0/2410.0.0.110.0.0.254254
192.168.1.0/24192.168.1.1192.168.1.254254
192.168.1.0/28192.168.1.1192.168.1.1414
172.16.0.0/12172.16.0.1172.31.255.2541,048,574

Subnetting a network

Dividing a larger network into smaller subnets is the core of network design.

Example: Split 10.0.0.0/24 into 4 equal subnets.

4 subnets requires 2 bits (2² = 4). Borrow 2 bits from the host portion: /24 + 2 = /26.

10.0.0.0/26   → 10.0.0.0 – 10.0.0.63    (hosts: 62)
10.0.0.64/26  → 10.0.0.64 – 10.0.0.127  (hosts: 62)
10.0.0.128/26 → 10.0.0.128 – 10.0.0.191 (hosts: 62)
10.0.0.192/26 → 10.0.0.192 – 10.0.0.255 (hosts: 62)

4 subnets × 62 hosts + 4 × 2 reserved (network/broadcast) = 256 total, matching the original /24.

IP classes (historical context)

Before CIDR, IP addresses were divided into classes:

ClassRangeDefault maskSize
A1.0.0.0–126.255.255.255/8 (255.0.0.0)16M hosts
B128.0.0.0–191.255.255.255/16 (255.255.0.0)65K hosts
C192.0.0.0–223.255.255.255/24 (255.255.255.0)254 hosts

Classful addressing wasted massive amounts of address space (a Class A block with 16M addresses assigned to a company needing 500 hosts). CIDR replaced classful addressing to allow variable-length subnet masks and reclaim address space.

Today, classes are mostly historical references. You may hear “Class C range” when someone means a /24 block — it’s technically imprecise but widely understood.

AWS, Azure, and GCP IP calculators

Cloud networking uses the same IP calculation rules. In AWS VPCs:

  • AWS reserves 5 IPs per subnet: network address, router IP, DNS IP, reserved for future, broadcast address
  • Usable hosts = 2^host_bits - 5
  • A /24 subnet has 256 - 5 = 251 usable host IPs

The Subnet Calculator shows both the standard 2-reserved and 5-reserved (AWS) host counts.


Related posts

Related tool

Subnet / CIDR Calculator

Calculate IPv4 subnets — network, broadcast, usable range, wildcard mask. Input CIDR (/24) or dotted mask (255.255.255.0). Binary visualization.

Written by Mian Ali Khalid. Part of the Dev Productivity pillar.