Subnet Calculator
Subnet Calculator: How to Calculate Subnets, CIDR, and Usable Hosts
Quick summary: A subnet calculator takes an IP address and a CIDR prefix (like /24) and instantly returns the network address, broadcast address, subnet mask, and number of usable host addresses. This guide breaks down the subnetting formula step by step, works through real /24 and /27 examples, and explains how to borrow bits to design your own subnets.
What Is a Subnet Calculator?
A subnet calculator is a tool that IT professionals and network administrators use to instantly and precisely calculate subnets on a network, including how many possible subnets a given network address block can support. Rather than manually converting IP addresses to binary and doing the math by hand, a subnet calculator does it instantly — computing the network address, broadcast address, usable host range, subnet mask, and CIDR notation from just an IP address and a prefix length.
It’s genuinely useful for network engineers, system administrators, and IT professionals planning networks, VLANs, cloud infrastructure, and security configurations, and it also doubles as a way to cross-check manual subnetting work before finalizing a router configuration.
CIDR Notation, Explained
CIDR notation expresses a subnet mask compactly using a forward slash followed by the number of network bits. For example, /24 means the first 24 bits of the 32-bit IPv4 address are the network portion, leaving 8 bits for hosts — which is equal to a traditional subnet mask of 255.255.255.0.
CIDR is based on the concept of subnetting; the two terms are practically interchangeable, though subnetting is usually used within an organization for internal networking, while CIDR is more often used by ISPs when allocating blocks of IP addresses. The higher the CIDR number, the smaller the subnet — a /32 represents a single host address, while /0 represents the entire internet address space.
The Subnet Calculator Formula
There are two formulas at the heart of every subnet calculator.
Formula 1: Usable Hosts
Usable Hosts = 2^(32 − CIDR prefix) − 2
The “− 2” accounts for two addresses every subnet reserves and can’t assign to a device: the network address (all host bits set to 0) and the broadcast address (all host bits set to 1).
Example: For a /24 subnet: 2^(32−24) − 2 = 2^8 − 2 = 256 − 2 = 254 usable hosts.
Formula 2: Number of Subnets (When Borrowing Bits)
To split a network into smaller subnets, you borrow bits from the host portion of the address. The number of subnets you get is:
Number of Subnets = 2^n
where n is the number of bits borrowed. Each borrowed bit doubles your subnet count while halving the host capacity of each subnet.
Worked Example 1: Sizing a Standard /24 Network
Say you’re assigned the network 192.168.1.0/24.
- Total addresses: 2^8 = 256 (since 32 − 24 = 8 host bits remain).
- Reserved addresses: 2 (network address 192.168.1.0, and broadcast address 192.168.1.255).
- Usable hosts: 256 − 2 = 254.
- Subnet mask: 255.255.255.0
- Wildcard mask: 0.0.0.255 — the inverse of the subnet mask, commonly used in Cisco ACLs and OSPF configurations.
Worked Example 2: Borrowing Bits to Create Smaller Subnets
Suppose you have a /24 network (254 usable hosts) but only need about 30 hosts per subnet, split across several teams.
- Determine bits needed for 30 hosts. You need 2^n − 2 ≥ 30, which is satisfied by 5 host bits (2^5 − 2 = 30).
- Borrow bits from the host portion. Starting from /24, borrowing 3 bits gives you a new prefix of /27 (24 + 3 = 27).
- Calculate subnets created: 2^3 = 8 subnets.
- Calculate hosts per subnet: 2^(8−3) − 2 = 2^5 − 2 = 30 usable hosts each.
- New subnet mask: /27 = 255.255.255.224.
So a single 192.168.1.0/24 network becomes eight separate /27 subnets, each supporting 30 devices — enough to isolate traffic between departments while avoiding wasted address space.
Common CIDR Values at a Glance
| CIDR | Subnet Mask | Usable Hosts |
|---|---|---|
| /8 | 255.0.0.0 | 16,777,214 |
| /16 | 255.255.0.0 | 65,534 |
| /24 | 255.255.255.0 | 254 |
| /27 | 255.255.255.224 | 30 |
| /30 | 255.255.255.252 | 2 |
| /31 | 255.255.255.254 | 2 (no network/broadcast reserved — point-to-point links only) |
| /32 | 255.255.255.255 | 1 (single host) |
Note the special case: a /31 subnet, defined in RFC 3021, provides exactly 2 usable addresses without reserving a network or broadcast address, making it ideal for point-to-point links between routers. A /32 represents a single host address, commonly used in routing tables and loopback interfaces.
Why Subnetting Matters
Dividing a larger network into subnets isn’t just an academic exercise. By borrowing bits from the host portion of an IP address, network administrators can create multiple logical networks within a single address block — this improves network security by isolating traffic between segments and reduces broadcast traffic that would otherwise reach every device on the network.
It’s also worth knowing that certain IP ranges are reserved for private, internal use and aren’t routable on the public internet. Most home routers default to 192.168.0.0/24 or 192.168.1.0/24, while enterprise networks commonly use 10.0.0.0/8 for maximum address flexibility.
Frequently Asked Questions
They express the same information in different formats. A subnet mask like 255.255.255.0 and CIDR notation like /24 both indicate that the first 24 bits of an address are the network portion.
Use the formula 2^(32 − CIDR prefix) − 2, subtracting 2 to account for the reserved network and broadcast addresses.
Every standard subnet reserves its first address as the network address and its last address as the broadcast address — neither can be assigned to an individual device.
Subnetting divides a network into smaller pieces (increasing the prefix length), typically done inside an organization; CIDR is also used for supernetting — combining smaller blocks into larger ones — and is used more broadly by ISPs for address allocation.
2^3 = 8 subnets, though each subnet will have fewer usable hosts since those bits are no longer available for host addresses.
A wildcard mask is the inverse of a subnet mask — where the subnet mask has a 1, the wildcard mask has a 0, and vice versa. For a /24 subnet mask (255.255.255.0), the wildcard mask is 0.0.0.255, commonly used in access control lists.
Related Calculators
- Currency Converter
- Time Zone
- Time Duration Calculator
- Online Stopwatch
- Hours Calculator
- Day Counter
- Day Of The Week Calculator
- Unit Converter
- Age Calculator
- Discount Calc
- Tip Calculator
- Alcohol Unit Calculator
- Molecular Weight Calculator
- Btu Calculator
- Golf Handicap Calculator
- Dew Point Calculator
- Roofing Calculator
- Wind Chill Calculator
- Horsepower Calculator
- Heat Index Calculator
- Gas Mileage Calculator
- Height Calculator
- Ohm’s Law Calculator
- Fuel Cost Calculator
- Password Generator
- Shoe Size Conversion Calculator
- Common Factor Calculator
- Tile Calculator
- Speed Calculator
- Engine Horsepower Calculator
- Tire Size Calculator
- Love Calculator
- Area Calculator
- Concrete Calculator
- Gravel Calculator
- Bra Size Calculator
- Image Compressor
- Bandwidth Calculator
- Molarity Calculator
- Resume-Maker-Online
- Sleep Calculator
Conclusion
A subnet calculator turns the binary math behind IP addressing into an instant, error-free result — but understanding the formula behind it matters just as much as the tool itself. Once you know how CIDR notation maps to a subnet mask, how to calculate usable hosts with 2^(32 − CIDR) − 2, and how borrowing bits multiplies your subnet count while dividing your host capacity, you can design, verify, and troubleshoot network layouts with confidence, whether you’re setting up a home router or planning enterprise VLANs.