# CIDR / Subnet Calculator

> Break down any IPv4 CIDR block into network and broadcast addresses, usable host range, host count, and netmask. Runs entirely in your browser.

- Tool: https://ronutz.com/en/tools/cidr
- Family: Networking

---

## What it does

The CIDR / Subnet Calculator takes an IPv4 block written in CIDR notation, an address together with a prefix length such as `192.168.1.0/24`, and derives everything that prefix implies: the network address, the broadcast address, the first and last usable host, the number of usable hosts, and the subnet mask in dotted-decimal form. It also classifies the block against the well-known reserved ranges, so a private block (RFC 1918) or another special-use block (RFC 6890) is flagged as such. Every calculation runs in your browser; no input is sent anywhere.

## How CIDR notation works

A prefix length `/n` fixes the leading `n` bits of the 32-bit address as the network portion and leaves the remaining `32 - n` bits for hosts. That one number sets the size of the block: it spans `2^(32 - n)` addresses. Within any block:

- the **network address** has every host bit set to 0 (the lowest address);
- the **broadcast address** has every host bit set to 1 (the highest);
- the **usable host range** is everything between them.

A /24, for example, spans `2^8 = 256` addresses: one network address, one broadcast address, and `254` usable hosts. In general, a block from /0 through /30 has `2^(32 - n) - 2` usable hosts, because the network and broadcast addresses are reserved and not assignable to hosts.

## The /31 and /32 edge cases

Two prefixes break the "minus two" rule:

- A **/32** describes a single host: one address, with no separate network or broadcast address.
- A **/31** describes exactly two addresses. On point-to-point links, RFC 3021 defines both of those addresses as usable, so a /31 provides two hosts with no reserved network or broadcast address. The calculator counts /31 blocks the RFC 3021 way.

## Worked examples

- `192.168.1.0/24`: network `192.168.1.0`, broadcast `192.168.1.255`, usable hosts `192.168.1.1` to `192.168.1.254`, `254` hosts, mask `255.255.255.0`.
- `10.0.0.0/30`: network `10.0.0.0`, broadcast `10.0.0.3`, usable hosts `10.0.0.1` to `10.0.0.2`, `2` hosts, mask `255.255.255.252`.
- `10.0.0.0/31`: two usable addresses (`10.0.0.0` and `10.0.0.1`), a point-to-point link per RFC 3021, with no network or broadcast address.

## Using it

Enter an IPv4 CIDR block such as `192.168.1.0/24` or `10.0.0.0/8`, and the tool reports the network and broadcast addresses, the usable host range, the host count, and the subnet mask. To see the reserved-range classification, enter a private block such as `10.0.0.0/8` (RFC 1918) or another special-use block; the tool flags what kind of block it is.

## Standards and references

- [RFC 4632 — Classless Inter-domain Routing (CIDR)](https://www.rfc-editor.org/rfc/rfc4632) - CIDR prefix arithmetic
- [RFC 1918 — Address Allocation for Private Internets](https://www.rfc-editor.org/rfc/rfc1918) - private-range classification
- [RFC 3021 — Using 31-Bit Prefixes on IPv4 Point-to-Point Links](https://www.rfc-editor.org/rfc/rfc3021) - /31 host counting
- [RFC 6890 — Special-Purpose IP Address Registries](https://www.rfc-editor.org/rfc/rfc6890) - special-use classification

## Related reading

- [A VLSM allocation, worked end to end](https://ronutz.com/en/learn/vlsm-worked-example.md): A full variable-length subnet allocation for a realistic network: sizing each segment, sorting largest-first, assigning the actual addresses, and accounting for the space left over.
- [CIDR notation explained](https://ronutz.com/en/learn/cidr-notation.md): What the slash in 192.168.1.0/24 actually means, and how a prefix length defines a block of IP addresses.
- [How IPv4 addresses work](https://ronutz.com/en/learn/ipv4-addressing.md): The 32 bits behind every dotted-quad address, and what private, loopback, and special ranges mean.
- [Private IPv4 address space and RFC 1918](https://ronutz.com/en/learn/private-address-space.md): The three private ranges, why they are not routable on the Internet, and the other special blocks the CIDR tool flags.
- [Route summarization](https://ronutz.com/en/learn/route-summarization.md): Why one summary route can replace many specific ones, the contiguous and aligned allocation it depends on, and the black-hole risk of summarizing a range you do not fully own.
- [Subnet overlaps and gaps](https://ronutz.com/en/learn/subnet-overlap-and-gaps.md): What it means for two prefixes to overlap or contain one another, why longest-prefix match makes some overlaps intentional, and how to find the unallocated gaps in an address plan.
- [Subnetting basics](https://ronutz.com/en/learn/subnetting-basics.md): How to divide one network into smaller subnets, and why borrowing host bits is the whole trick.
- [Supernetting and route aggregation](https://ronutz.com/en/learn/supernetting-and-aggregation.md): How contiguous prefixes combine into a shorter one, the alignment rule that decides whether two blocks can merge, and the difference between exact aggregation and a single covering supernet.
- [VLSM: splitting a block into unequal subnets](https://ronutz.com/en/learn/vlsm.md): How to carve one address block into subnets of different sizes without wasting space, and the largest-first rule that keeps it tidy.
