Subnet / CIDR Calculator
Compute the network and broadcast addresses, usable host range, host count, subnet mask and wildcard mask for any IPv4 address and CIDR prefix.
/
Network 192.168.1.0/24
- 1
Host bits
32 − 24 = 8 - 2
Total addresses
2⁸ = 256 - 3
Usable hosts
256 − 2 = 254Two addresses are reserved: the network address and the broadcast address.
How does this calculator work?
Enter an IPv4 address and CIDR prefix to get the network and broadcast addresses, the first and last usable host, the total usable host count, and the subnet and wildcard masks. The mask is formed from the prefix, the network is IP AND mask, and usable hosts equal 2^(32−prefix)−2.
Formula
How this is calculated
The IPv4 address is parsed from dotted-decimal notation into a single 32-bit unsigned integer, with each of the four octets occupying 8 bits. The prefix length (the number after the slash in CIDR notation, 0–32) tells you how many leading bits identify the network; the remaining bits identify hosts within that network.
The subnet mask is built by shifting all-ones left by (32 − prefix) bits, so the network bits are 1 and the host bits are 0. The network address is the bitwise AND of the IP and the mask (host bits cleared to 0). The broadcast address ORs the network with the wildcard mask (the inverted subnet mask), setting every host bit to 1. The first usable host is the network address plus one and the last usable host is the broadcast address minus one.
Usable hosts equal 2^(32 − prefix) − 2, because the network and broadcast addresses cannot be assigned to a device. Two prefixes are special cases: a /31 has exactly 2 usable addresses (RFC 3021 point-to-point links use both), and a /32 describes a single host with 1 address. All arithmetic uses unsigned 32-bit operations (>>> 0) so results never go negative.
Frequently asked questions
In a normal subnet the first address is reserved as the network identifier and the last address is the broadcast address, so neither can be assigned to a device. That is why usable hosts equal the total addresses minus two for prefixes /30 and shorter.
The wildcard mask is the bitwise inverse of the subnet mask: where the mask has 1s the wildcard has 0s and vice versa. It is commonly used in access control lists and routing rules to indicate which bits of an address may vary.
A /32 represents a single host (one address, used for loopbacks or host routes). A /31 yields two addresses with no network/broadcast reservation, which RFC 3021 allows for point-to-point links so both ends are usable.
Also known as
TG we-Calculate Editorial Team. (2026). Subnet / CIDR Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/subnet-calculator
TG we-Calculate Editorial Team. "Subnet / CIDR Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/subnet-calculator.
TG we-Calculate Editorial Team, "Subnet / CIDR Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/subnet-calculator
@misc{wecalculate_subnet_calculator, title = {Subnet / CIDR Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/subnet-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
