IMD SolutionComputing LibraryShop main store

CIDR subnet calculator

Enter an IPv4 address and the prefix length and get the network, mask, broadcast and the range of usable host addresses.

Calculator

This calculator needs JavaScript. Without it, use the formulas under "How it works" and the worked example.

How it works

An IPv4 address is four numbers that together make one 32-bit value. The prefix length after the slash says how many of those bits name the network. The rest, 32 minus the prefix, count the addresses inside it.

  • Total addresses = 2 to the power of (32 - prefix).
  • Network address = the address with the host bits set to 0. Broadcast = the same with the host bits set to 1.
  • Subnet mask = the prefix written as four numbers, for example /24 is 255.255.255.0. Wildcard mask = the mask turned inside out.
  • Usable hosts = the address count - 2 for a /30 or larger network, because the network and broadcast addresses are not given to devices.

A /31 has two addresses and both are usable on a point-to-point link (RFC 3021), and a /32 is one address. The address type line only reads the number against the reserved blocks, such as the three private ranges in RFC 1918, and does not know your plant plan.

Worked example

A packaging line puts its controllers on 192.168.10.37 with a prefix of /26. A /26 leaves 6 host bits, so the network holds 64 addresses. The block that contains .37 starts at 192.168.10.0/26, uses the mask 255.255.255.192 and ends at the broadcast address 192.168.10.63.

Devices can use 192.168.10.1 to 192.168.10.62, which is 62 hosts. A device at 192.168.10.70 sits in the next /26 and needs a router to reach .37.

Common mistakes

  • Reading a mask of 255.255.0.0 as a /24. Count the 1 bits: this one is /16, with 65,536 addresses.
  • Placing two devices in the same network because the first three numbers match. The prefix decides the boundary, and a /26 splits a .0 to .255 block into four.
  • Giving a device the network or broadcast address. Both are reserved on a /30 or larger network.
  • Using a mask on the PC that differs from the controller. Each side then calculates a different network and they may not reach each other without a router.
  • Overlapping two subnets when a plant network is extended, which makes routes ambiguous.

Related articles

Other calculators