Tech

Subnet (CIDR) calculator

IPv4 CIDR subnet info: network, broadcast, mask, hosts, class, and address-space split.

01Inputs
02Results
Network
Broadcast
Subnet mask
Wildcard mask
Class / privacy
·
First host
Last host
Total addresses
Usable hosts
Binary mask
Address space split (32 bits)
03How it works

Why this calculation

Every network engineer, system administrator, and DevOps practitioner who has ever defined a VLAN, configured a firewall rule, sized a Kubernetes service CIDR, or split an AWS VPC into subnets has solved the same arithmetic: given an IPv4 address and a CIDR prefix, what are the network address, the broadcast address, the usable host range, the subnet mask in dotted-decimal, the wildcard mask for ACLs, and how many hosts can the prefix accommodate? The arithmetic is bit-level — apply the mask to the address, invert the mask for the wildcard, count host bits — and is straightforward when the prefix is a "byte boundary" (/8, /16, /24) but error-prone otherwise. Subnet calculators are the most-bookmarked tool in any network admin's browser. This calculator runs in-page so it works offline (training, certification prep, air-gapped lab environments).

The output goes beyond the bare numbers: the calculator labels the address class (A/B/C/D/E for legacy reference), flags whether the address is in RFC 1918 private space (10/8, 172.16/12, 192.168/16), shows the binary subnet mask for visual verification, and renders a stacked bar that visualizes how the 32 address bits split between the network prefix and the host portion. The bar makes the key insight of CIDR concrete: as the prefix grows from /16 to /20 to /24 to /28, the host portion shrinks and the count of available hosts plummets exponentially.

The formula

An IPv4 address is 32 bits, conventionally written as four dotted decimal octets (192.168.1.42 = 11000000.10101000.00000001.00101010). A CIDR prefix /N (0 ≤ N ≤ 32) declares how many high bits are the network portion; the remaining 32 − N bits are the host portion.

  • Subnet mask = N high bits 1, low bits 0. /24 → 11111111.11111111.11111111.00000000 → 255.255.255.0.
  • Wildcard mask = bitwise NOT of the subnet mask. /24 → 0.0.0.255.
  • Network address = address AND mask. 192.168.1.42 / 24 → 192.168.1.0.
  • Broadcast address = network OR wildcard. 192.168.1.0 / 24 → 192.168.1.255.
  • Total addresses = 2^(32−N).
  • Usable hosts = 2^(32−N) − 2 for normal subnets (subtract network and broadcast). Special cases: /31 (point-to-point links, RFC 3021) has 2 usable hosts; /32 has 1 usable host (a single-host route).
  • First host = network + 1 (or network itself for /31, /32).
  • Last host = broadcast − 1 (or broadcast itself for /31, /32).

Address class (legacy classful conventions, deprecated since 1993 CIDR but still useful for shorthand):

  • Class A: 1.0.0.0 – 127.255.255.255 (first bit 0).
  • Class B: 128.0.0.0 – 191.255.255.255 (first two bits 10).
  • Class C: 192.0.0.0 – 223.255.255.255 (first three bits 110).
  • Class D (multicast): 224.0.0.0 – 239.255.255.255.
  • Class E (reserved): 240.0.0.0 – 255.255.255.255.

Private (RFC 1918): 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16. Plus 100.64.0.0/10 (CGN, RFC 6598) and 169.254.0.0/16 (link-local, APIPA) — not flagged in this calculator's simplified privacy detection.

How to use

Enter the IPv4 address in dotted-decimal notation. Enter the CIDR prefix as an integer between 0 and 32 (typical values: /8, /16, /24, /28, /30). The result panel renders network, broadcast, subnet mask, wildcard mask, first usable host, last usable host, total addresses, usable hosts, address class, RFC 1918 private/public flag, and the binary subnet mask. The stacked bar visualizes the network/host split.

Worked example

Home /24 LAN: 192.168.1.0 / 24.

  • Mask: 255.255.255.0 = 11111111.11111111.11111111.00000000.
  • Network: 192.168.1.0. Broadcast: 192.168.1.255.
  • First host: 192.168.1.1. Last host: 192.168.1.254.
  • Total: 256 addresses. Usable hosts: 254.
  • Class C, private (RFC 1918).

Small /28 office: 10.0.5.16 / 28.

  • Host bits: 32 − 28 = 4. Mask: 255.255.255.240 = ...11110000.
  • Network: 10.0.5.16 (the /28 boundary is at every multiple of 16 in the last octet).
  • Broadcast: 10.0.5.31.
  • First / last host: 10.0.5.17 / 10.0.5.30. Usable: 14.
  • Class A, private.

Large /16 corporate: 172.16.0.0 / 16.

  • Mask: 255.255.0.0. Network: 172.16.0.0. Broadcast: 172.16.255.255.
  • First host: 172.16.0.1. Last host: 172.16.255.254. Usable: 65 534.
  • Class B, private.

Point-to-point /31: 10.0.0.0 / 31. Per RFC 3021, both addresses (10.0.0.0 and 10.0.0.1) are usable as endpoints — no broadcast/network reservation needed for point-to-point links.

Single-host /32: 10.0.0.5 / 32. Network = broadcast = first = last = 10.0.0.5. Usable: 1. Used in OSPF stub-route advertisements, AWS security-group rules, and host-route-only configurations.

Pitfalls

Off-by-one on host count. Standard subnets reserve network + broadcast — usable = 2^(32−N) − 2. /31 and /32 are exceptions; the calculator handles them but most practitioners need to think twice when working in those edge prefixes.

CIDR vs classful network masks. Pre-1993, networks were classful (class A = /8, class B = /16, class C = /24). Modern CIDR allows any prefix length; many old documentation references and legacy network appliances still print classful masks. The calculator uses CIDR; the class label is informational only.

Endianness in mask printing. The dotted-decimal notation is "big-endian" — high-order bits (network bits) on the left. Some legacy systems printed the wildcard mask with bits reversed. Always cross-check the dotted-decimal mask against the binary representation.

Subnet-zero confusion. Old-school IOS forbade the "subnet zero" (the lowest subnet of a classful range, e.g. 192.168.1.0 / 25 in a 192.168.1.0 / 24 classful range). Modern software has ip subnet-zero enabled by default and the restriction is irrelevant; some legacy documentation perpetuates it.

RFC 1918 isn't the only private. The calculator's private-flag check matches 10/8, 172.16/12, 192.168/16. It does not flag CGN (100.64/10), link-local (169.254/16), loopback (127/8), or documentation ranges (192.0.2/24, 198.51.100/24, 203.0.113/24). Cross-reference manually for those.

Multicast / experimental ranges. Class D (multicast 224/4) and Class E (240/4) work in the calculator arithmetic but their semantics are not unicast; usable-host counts are not meaningful there.

Variable-length subnet masking (VLSM). The calculator handles one prefix at a time. For a multi-subnet design, run the calculator multiple times against the parent block, sub-divided.

Network address vs first usable host. In /30 and longer (smaller subnets), the math gets cramped — /30 has 4 addresses (0, 1, 2, 3), of which only 1 and 2 are usable.

IPv6 is fundamentally different. CIDR concept transfers, but the address space is 128 bits, the math is in hex, and broadcast doesn't exist. This calculator is IPv4 only.

Big-O on huge usable-host counts. /8 has 16.7 million addresses; the calculator returns the count but obviously not the list. Don't expect to enumerate every host in a /16 or smaller prefix.

Leading zeros in IP. "192.168.001.042" is not standard; the calculator's parser tolerates it but RFC 791 says octets are integers without leading zeros. Some libraries (POSIX inet_aton) interpret leading zeros as octal — a notorious surprise.

Subnet boundary discipline. /28 networks always align on a multiple of 16 in the last octet; entering 10.0.0.5 / 28 returns network 10.0.0.0, not 10.0.0.5. The calculator does the masking automatically — useful sanity check.

Variations

  • VLSM planner: split a parent CIDR into multiple smaller subnets sized to host counts.
  • IPv6 prefix calculator: same machinery on 128-bit addresses, hex notation.
  • Number-of-subnets calculator: given a parent CIDR and a target /N, how many sub-blocks fit.
  • Wildcard-bit / ACL planner: convert prefix to ACL wildcard and back.
  • Route summarization: given a list of /24s, find the smallest prefix that covers them all.

Related calculators