How to Calculate Subnets: CIDR, Masks & IP Ranges Explained (2026)
Subnetting is a fundamental networking skill. Whether you are designing a network, configuring firewalls, or studying for a certification exam, this guide walks you through CIDR notation, subnet masks, and how to calculate network and host ranges from scratch.
What Are Subnets?
A subnet (short for subnetwork) is a logical subdivision of an IP network. Subnetting divides a large network into smaller, more manageable segments. Each subnet has its own range of IP addresses, a network address, and a broadcast address. Subnets improve network performance by reducing broadcast traffic and enhance security by isolating network segments.
For example, a company with a single /16 network (65,536 addresses) might split it into 256 /24 subnets (256 addresses each) — one per department or floor. Each subnet operates as its own broadcast domain, and traffic between subnets must pass through a router.
CIDR Notation
CIDR (Classless Inter-Domain Routing) notation is the standard way to express an IP address and its associated network mask. It uses a slash followed by the number of network bits. For example:
192.168.1.0/24— The first 24 bits are the network portion, leaving 8 bits for host addresses (256 total addresses, 254 usable).10.0.0.0/8— The first 8 bits are the network portion, leaving 24 bits for hosts (16,777,216 total addresses).172.16.0.0/12— The first 12 bits are the network portion, leaving 20 bits for hosts (1,048,576 total addresses).
The higher the CIDR number, the smaller the subnet. A /32 is a single host, while a /0 represents the entire IPv4 address space.
Subnet Masks
A subnet mask is a 32-bit number that separates the network portion of an IP address from the host portion. It is written in dotted decimal notation, just like an IP address. The network bits are set to 1 and the host bits are set to 0.
Common subnet masks and their CIDR equivalents:
255.255.255.0= /24 (256 addresses)255.255.0.0= /16 (65,536 addresses)255.0.0.0= /8 (16,777,216 addresses)255.255.255.128= /25 (128 addresses)255.255.255.192= /26 (64 addresses)
Binary Calculation: How Subnetting Works Under the Hood
To truly understand subnetting, you need to think in binary. An IPv4 address is 32 bits divided into four octets. For example, the IP address 192.168.1.130 in binary is:
11000000.10101000.00000001.10000010With a /25 subnet mask (255.255.255.128), the first 25 bits are the network portion and the last 7 bits are for hosts. The subnet mask in binary is:
11111111.11111111.11111111.10000000To find the network address, perform a bitwise AND between the IP address and the subnet mask. To find the broadcast address, set all host bits to 1. The usable host range is everything between the network address + 1 and the broadcast address - 1.
How to Calculate Network, Broadcast & Host Range
Let us work through a complete example. Given the IP address 192.168.1.130/26:
- Subnet mask: /26 =
255.255.255.192(26 network bits, 6 host bits). - Block size: 2^6 = 64 addresses per subnet.
- Network address: 130 falls in the 128-191 block, so the network address is
192.168.1.128. - Broadcast address: 128 + 64 - 1 =
192.168.1.191. - Usable host range:
192.168.1.129to192.168.1.190(62 usable hosts).
Common Subnet Sizes
Here are the most commonly used subnet sizes and their typical use cases:
- /24 (256 addresses, 254 usable) — The most common subnet size for small to medium networks. Default for many home routers and small office networks.
- /16 (65,536 addresses) — Used for large organizational networks. The classic Class B equivalent.
- /8 (16,777,216 addresses) — Massive networks, typically allocated to ISPs or large enterprises. The 10.0.0.0/8 range is commonly used for private networks.
- /28 (16 addresses, 14 usable) — Small segments for point-to-point links or very small departments.
- /30 (4 addresses, 2 usable) — Point-to-point links between routers.
- /32 (1 address) — A single host route, often used in routing tables and loopback interfaces.
VLSM (Variable Length Subnet Masking)
VLSM allows you to use different subnet sizes within the same network, optimizing IP address utilization. Instead of assigning a uniform /24 to every department — wasting addresses where only 10 hosts exist — you can assign a /28 (14 hosts) to small departments and a /23 (510 hosts) to large ones.
The key rule with VLSM is to allocate the largest subnets first, then subdivide the remaining space for smaller subnets. This prevents address overlap and makes efficient use of your allocated IP block.
Use Our Subnet Calculator
Skip the manual calculation and use our free online tool to instantly calculate network addresses, broadcast addresses, host ranges, and wildcard masks for any CIDR prefix:
- Subnet Calculator — Enter any IP address and CIDR prefix to get instant results.
- DNS Lookup — Resolve domain names to IP addresses for subnet analysis.
- IP Geolocation — Look up the geographic location and network information for any IP address.