Subnet Calculator

Subnet Calculator
Networking

Subnet Calculator

Enter either a CIDR prefix or a dotted subnet mask — whichever you fill in last will be used.
Please enter a valid IPv4 address and either a CIDR prefix (0–32) or a valid subnet mask.
Network Address
CIDR
Subnet Mask
Wildcard Mask
Broadcast Address
First Usable Host
Last Usable Host
Usable Hosts
Total Addresses
IP Class
Disclaimer: This tool performs standard IPv4 subnetting arithmetic for general reference and educational use. It does not validate reachability, routing, or organizational IP addressing policy. Confirm results against your network documentation before making configuration changes.

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.

  1. Total addresses: 2^8 = 256 (since 32 − 24 = 8 host bits remain).
  2. Reserved addresses: 2 (network address 192.168.1.0, and broadcast address 192.168.1.255).
  3. Usable hosts: 256 − 2 = 254.
  4. Subnet mask: 255.255.255.0
  5. 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.

  1. Determine bits needed for 30 hosts. You need 2^n − 2 ≥ 30, which is satisfied by 5 host bits (2^5 − 2 = 30).
  2. Borrow bits from the host portion. Starting from /24, borrowing 3 bits gives you a new prefix of /27 (24 + 3 = 27).
  3. Calculate subnets created: 2^3 = 8 subnets.
  4. Calculate hosts per subnet: 2^(8−3) − 2 = 2^5 − 2 = 30 usable hosts each.
  5. 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

CIDRSubnet MaskUsable Hosts
/8255.0.0.016,777,214
/16255.255.0.065,534
/24255.255.255.0254
/27255.255.255.22430
/30255.255.255.2522
/31255.255.255.2542 (no network/broadcast reserved — point-to-point links only)
/32255.255.255.2551 (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

What is the difference between a subnet mask and CIDR notation?

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.

How do I calculate the number of usable hosts in a subnet?

Use the formula 2^(32 − CIDR prefix) − 2, subtracting 2 to account for the reserved network and broadcast addresses.

Why do I subtract 2 from the total number of 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.

What’s the difference between subnetting and CIDR/supernetting?

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.

How many subnets do I get if I borrow 3 bits?

2^3 = 8 subnets, though each subnet will have fewer usable hosts since those bits are no longer available for host addresses.

What is a wildcard mask, and how is it different from a subnet mask?

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

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.