IP Subnet Calculator

An IPv4 prefix such as /24 says how many leading bits identify the network. The rest identify hosts, which fixes the network address, the broadcast address and how many devices fit.

Also called: CIDR calculator · Subnet mask calculator

  • Last updated
  • Formula tested against reference values

Your numbers

Ignored if you type the prefix after the address, as in 10.0.0.0/8.

Result

Network (CIDR)
—

Calculating…

Network address
—
Broadcast address
—
First usable host
—
Last usable host
—
Usable hosts
—
Total addresses
—
Subnet mask
—
Wildcard mask
—
Mask in binary
—
Address type
—

How to use this calculator

  1. Enter or choose iPv4 address.
  2. Enter or choose prefix length (CIDR).
  3. The network (CIDR) updates as you type. Use Copy result or Share to keep it.

Method

Block size = 2^(32 − prefix); Network = ⌊address ÷ block⌋ × block; Broadcast = Network + block − 1; Usable hosts = block − 2 (2 for /31, 1 for /32)

prefix
number of network bits (0–32)
block
number of addresses in the subnet

Worked example

  1. A /24 leaves 32 − 24 = 8 host bits, so the block is 2⁸ = 256 addresses.
  2. The network address keeps the first three octets and sets the last to 0: 192.168.1.0.
  3. The broadcast address sets all host bits to 1: 192.168.1.255.
  4. Usable hosts are 256 − 2 = 254, from 192.168.1.1 to 192.168.1.254.

192.168.1.10/24 is in network 192.168.1.0/24, with 254 usable addresses from .1 to .254 and mask 255.255.255.0.

What the result means

Devices on the same subnet talk directly; anything outside goes through a router. Pick the smallest subnet that leaves room to grow: a /26 holds 62 hosts, a /25 126 and a /24 254.

Assumptions and limits

  • IPv4 only.
  • The network and broadcast addresses are not assigned to hosts, except in /31 point-to-point links (RFC 3021) and single-host /32 routes.
  • IPv6 subnets are not calculated.
  • Address type labels cover the main special ranges (private, loopback, link-local, CGNAT, multicast), not every reserved block.

Questions

What is a wildcard mask?

The inverse of the subnet mask (0.0.0.255 for /24). Cisco access lists and OSPF use it to say which bits may vary.

Why are two addresses not usable?

In a normal subnet the all-zeros host address names the network itself and the all-ones address is the broadcast address.