The IPv4 subnet calculator accepts an address with CIDR notation, a subnet mask, a Cisco wildcard mask, a required host count, or an address range. It returns the canonical network, broadcast or last address, usable host range, address count, netmask, and wildcard mask. A second CIDR prefix can split a network into smaller subnets or aggregate it into a supernet.
Accepted Input Formats
| Task | Example |
|---|---|
| Calculate a CIDR network | 192.168.1.42/24 |
| Use a dotted subnet mask | 192.168.1.42 255.255.255.0 |
| Use a Cisco wildcard mask | 10.0.0.1 0.0.0.63 |
| Find a subnet for a host requirement | 10.0.0.0#1000 |
| Cover an address range | 192.168.0.9-192.168.1.20 |
| Split a parent network | 192.168.2.70/24/26 |
| Aggregate into a supernet | 192.168.2.70/27/24 |
A bare IPv4 address is treated as a single-host /32 route. This avoids the obsolete classful assumption that an address beginning with 10, 172, or 192 automatically implies a particular network size.
How CIDR Defines an IPv4 Network
An IPv4 address contains 32 bits. In the notation 192.168.1.42/24, the prefix length 24 assigns the first 24 bits to the network and leaves 8 host bits. The subnet mask therefore contains 24 leading one-bits followed by 8 zero-bits:
11111111.11111111.11111111.00000000
255.255.255.0 Applying that mask with a bitwise AND clears the host portion and produces the network address. Setting every host bit to one produces the broadcast address. For prefix length \(p\), the total number of addresses is
\[ N_{\mathrm{addresses}} = 2^{32-p}. \] For prefixes from /0 through /30, the conventional usable-host count excludes the network and broadcast addresses:
The /31 and /32 Exceptions
A /32 identifies one address and is commonly used for host routes. A /31 contains two addresses. Under RFC 3021, both endpoints are usable on a point-to-point link because that link does not need a broadcast address. The calculator follows this modern rule, reporting two usable addresses for /31 and one for /32.
Subnet Masks and Wildcard Masks
A valid subnet mask has one contiguous run of one-bits followed by zero-bits. The wildcard mask is its bitwise inverse, so 255.255.255.192 and 0.0.0.63 both describe a /26. Wildcard masks commonly appear in router access-control lists. Non-contiguous values such as 255.0.255.0 are rejected because they do not identify one CIDR prefix.
Reverse Subnetting From a Host Requirement
With #1000, the calculator chooses the longest prefix whose usable range can still hold at least 1,000 addresses. A /23 provides only 510 conventional host addresses, while a /22 provides 1,022, so /22 is the smallest suitable block. Real network plans should also reserve capacity for gateways, infrastructure, future growth, and any platform-specific address reservations.
Subnetting, Supernetting, and Range Coverage
In a two-prefix expression such as 192.168.2.70/24/26, the first prefix describes the parent network and the longer second prefix describes each child. The difference of two prefix bits creates \(2^2=4\) equal /26 subnets. Reversing the relationship, as in /27/24, aggregates the address into the containing /24 supernet.
For an address range, the result is the smallest single CIDR block containing both endpoints. CIDR blocks must begin on power-of-two boundaries, so the resulting network can include addresses outside the requested range. Multiple CIDR blocks are required when an exact range decomposition is needed.
References
- [RFC1918]Y. Rekhter et al., Address Allocation for Private Internets, RFC 1918, 1996.
- [RFC3021]A. Retana et al., Using 31-Bit Prefixes on IPv4 Point-to-Point Links, RFC 3021, 2000.
- [RFC4632]V. Fuller and T. Li, Classless Inter-domain Routing (CIDR), RFC 4632, 2006.