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...
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:
- Network address — the first IP in the range (host bits all 0)
- Broadcast address — the last IP in the range (host bits all 1)
- First usable host — network address + 1
- 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
| CIDR | First IP | Last IP | Hosts |
|---|---|---|---|
| 10.0.0.0/8 | 10.0.0.1 | 10.255.255.254 | 16,777,214 |
| 10.0.0.0/16 | 10.0.0.1 | 10.0.255.254 | 65,534 |
| 10.0.0.0/24 | 10.0.0.1 | 10.0.0.254 | 254 |
| 192.168.1.0/24 | 192.168.1.1 | 192.168.1.254 | 254 |
| 192.168.1.0/28 | 192.168.1.1 | 192.168.1.14 | 14 |
| 172.16.0.0/12 | 172.16.0.1 | 172.31.255.254 | 1,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:
| Class | Range | Default mask | Size |
|---|---|---|---|
| A | 1.0.0.0–126.255.255.255 | /8 (255.0.0.0) | 16M hosts |
| B | 128.0.0.0–191.255.255.255 | /16 (255.255.0.0) | 65K hosts |
| C | 192.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 tools
- Subnet Calculator — calculate network ranges and host counts
- CIDR Notation — what /24, /16, /8 mean
- Private IP Address Ranges — RFC 1918 address ranges
Related posts
- Private IP Address Ranges, Subnets, and CIDR Notation Explained — The three RFC 1918 private ranges, what CIDR notation actually means, subnet mas…
- CIDR Notation Explained — What /24, /16, /8 Mean in IP Addresses — CIDR notation is the slash number after an IP address — /24, /16, /8. It specifi…
- DHCP IP Allocation — How Dynamic IP Assignment Works — DHCP (Dynamic Host Configuration Protocol) automatically assigns IP addresses, s…
- Subnetting Guide — How to Calculate Subnet Masks and IP Ranges — Subnetting divides a network into smaller subnetworks. Here's how CIDR notation,…
Related tool
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.