Subnetting Explained: How to Calculate Subnet Masks and IP Ranges
Subnetting is one of the fundamental skills in networking, yet it trips up students and professionals alike. The good news is that the logic behind it is consistent and learnable. This guide explains IP subnetting from the ground up — what it is, why it matters, and exactly how to calculate subnet sizes and IP ranges.
What Is Subnetting and Why Does It Matter?
An IP address (version 4) is a 32-bit number written in four decimal octets, like 192.168.1.100. The internet and private networks would be unmanageable if every device was on one giant flat network — traffic would be overwhelming and security would be impossible. Subnetting divides large networks into smaller, more manageable segments called subnets.
Subnets improve performance by limiting broadcast domains (devices that hear each other's broadcast traffic), improve security by isolating sensitive systems from general traffic, and allow efficient use of limited IP address space.
Understanding CIDR Notation
CIDR (Classless Inter-Domain Routing) notation expresses a subnet as an IP address followed by a slash and a prefix length: 192.168.1.0/24. The number after the slash (the prefix length) tells you how many bits of the address are the network portion, with the remaining bits identifying individual hosts.
A /24 prefix means 24 bits are the network address and 8 bits identify hosts. Since 8 bits can represent 256 values (0–255), a /24 subnet contains 256 addresses. However, 2 of those are reserved: the network address (all host bits = 0) and the broadcast address (all host bits = 1). So a /24 has 254 usable host addresses.
Common CIDR Subnets Quick Reference
- /32: 1 address — single host route or loopback
- /30: 4 addresses, 2 usable — point-to-point links (router to router)
- /29: 8 addresses, 6 usable — very small subnets
- /28: 16 addresses, 14 usable — small office VLANs
- /27: 32 addresses, 30 usable — small networks
- /26: 64 addresses, 62 usable — medium segments
- /25: 128 addresses, 126 usable — half a class C
- /24: 256 addresses, 254 usable — standard office subnet
- /23: 512 addresses, 510 usable
- /22: 1,024 addresses, 1,022 usable
- /16: 65,536 addresses, 65,534 usable — class B equivalent
- /8: 16,777,216 addresses — class A equivalent
Calculating Subnet Ranges Step by Step
Given a subnet 10.0.1.0/26, find the network address, broadcast address, first host, last host, and number of usable hosts:
Step 1: Determine the block size. /26 means 32 − 26 = 6 host bits. Block size = 2^6 = 64.
Step 2: Network address is 10.0.1.0 (given, with last octet starting at 0).
Step 3: Broadcast address = network address + block size − 1 = 10.0.1.0 + 64 − 1 = 10.0.1.63.
Step 4: First usable host = 10.0.1.1 (network address + 1).
Step 5: Last usable host = 10.0.1.62 (broadcast address − 1).
Step 6: Usable hosts = 64 − 2 = 62.
The Subnet Mask
Subnet masks are an older way of expressing the same information as CIDR prefix lengths. A /24 subnet has a subnet mask of 255.255.255.0 — the 24 "on" bits correspond to the three octets of 255, and the 8 "off" bits correspond to the final 0.
- /24 = 255.255.255.0
- /25 = 255.255.255.128
- /26 = 255.255.255.192
- /27 = 255.255.255.224
- /28 = 255.255.255.240
- /29 = 255.255.255.248
- /30 = 255.255.255.252
Private IP Address Ranges
Certain IP ranges are reserved for private network use and are not routable on the public internet:
- 10.0.0.0/8 — 10.0.0.0 to 10.255.255.255 (16.7 million addresses)
- 172.16.0.0/12 — 172.16.0.0 to 172.31.255.255 (1 million addresses)
- 192.168.0.0/16 — 192.168.0.0 to 192.168.255.255 (65,536 addresses)
Home routers typically use 192.168.0.x or 192.168.1.x. Enterprise networks often use 10.x.x.x for maximum flexibility. The 172.16.0.0/12 range is commonly used by cloud providers for VPC (Virtual Private Cloud) networks.
🌐 Calculate any subnet instantly with our free Subnet Calculator — CIDR, host ranges, and masks.
Try the Subnet Calculator →Key Takeaways
- Subnets divide networks into segments for performance, security, and address efficiency
- CIDR /24 = 256 total addresses, 254 usable — the most common office subnet
- Block size = 2^(32−prefix length). Network + broadcast addresses are always reserved
- Private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
- Use /30 for point-to-point links, /24 for standard office segments, /16 for large campuses