InfyCalculator
💻

Subnet Calculator

Enter an IPv4 address and CIDR prefix to get the network and broadcast addresses, subnet mask, wildcard mask, usable host range and host count.

IPv4 address
CIDR prefix (/n)
Loading calculator…

How it works

mask = 0xFFFFFFFF << (32 − prefix) · network = ip AND mask · broadcast = network OR (NOT mask) · usable hosts = 2^(32−prefix) − 2 (for /0–/30)

A subnet mask splits a 32-bit IPv4 address into a network part (the leading prefix bits, all 1s) and a host part (the trailing bits, all 0s). ANDing the address with the mask zeroes the host bits to give the network address; ORing in the inverted mask (the wildcard) sets them all to give the broadcast address. Everything between those two is a usable host, which is why a block of 2^(32−prefix) addresses offers two fewer usable hosts — the network and broadcast addresses are reserved. The /31 and /32 prefixes break that rule: /31 dedicates both addresses to a point-to-point link, and /32 is a single host route.

Worked example

192.168.1.10 with a /24 prefix: the mask is 255.255.255.0, so the network is 192.168.1.0 and the broadcast is 192.168.1.255. Usable hosts run 192.168.1.1 through 192.168.1.254 — 256 total addresses minus 2 reserved = 254 hosts, with a wildcard mask of 0.0.0.255.

Sources: RFC 4632 — CIDR · RFC 3021 — Using /31 prefixes

Frequently asked questions

Why are two addresses subtracted from the host count?

The first address in a subnet is the network identifier and the last is the broadcast address; neither can be assigned to a device. So a /24 has 256 addresses but only 254 usable hosts. The exception is /31, where RFC 3021 lets both addresses serve a two-node point-to-point link.

What is the wildcard mask for?

It is the bitwise inverse of the subnet mask (0.0.0.255 for a /24) and marks which bits can vary. Access control lists on Cisco and other gear match addresses against a wildcard rather than a subnet mask, so this converter shows both.

How does the prefix relate to the dotted mask?

The prefix is simply the count of leading 1-bits in the mask: /24 = 24 ones = 255.255.255.0, /26 = 255.255.255.192, /30 = 255.255.255.252. Every extra prefix bit halves the block size and, roughly, the usable host count.

Related calculators

This calculator is for educational purposes. Double-check important results before acting on them.