IPv4 network planning

Subnet calculator

Calculate CIDR networks, masks, host ranges, wildcard masks, subnets, and supernets.

Online IP Subnet Calculator

Robert Eisele

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

TaskExample
Calculate a CIDR network192.168.1.42/24
Use a dotted subnet mask192.168.1.42 255.255.255.0
Use a Cisco wildcard mask10.0.0.1 0.0.0.63
Find a subnet for a host requirement10.0.0.0#1000
Cover an address range192.168.0.9-192.168.1.20
Split a parent network192.168.2.70/24/26
Aggregate into a supernet192.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:

\[ N_{\mathrm{hosts}} = 2^{32-p} - 2. \]

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