How this calculator works
An IPv4 address is 32 bits. The prefix length says how many leading bits describe the network and how many trailing bits describe hosts. The subnet mask is a row of prefix ones followed by zeros, so a /24 is 255.255.255.0. A bitwise AND of the address and the mask gives the network address, and a bitwise OR with the wildcard mask gives the broadcast address. Everything between them is the host range. Practically, the network address names the block, the broadcast address reaches every host at once, and both are reserved, which is why a /24 has 256 addresses but only 254 usable hosts. Point-to-point links use /31 to avoid waste.
Formula
subnet mask = prefix ones followed by zeros. network address = IP address AND subnet mask. broadcast address = network address OR wildcard mask. wildcard mask = NOT subnet mask. total addresses = 2^(32 - prefix). usable hosts = total addresses - 2 for a /30 or larger block.
Worked example
For 192.168.1.10/24, the mask is 255.255.255.0 and ANDing gives the network 192.168.1.0. The wildcard mask is 0.0.0.255, so the broadcast address is 192.168.1.255. The usable hosts run from 192.168.1.1 to 192.168.1.254, which is 254 of the 256 addresses in the block.
Advertisement
Frequently asked questions
Why are two addresses always unusable?
The first address identifies the network and the last is the directed broadcast for the whole subnet. Neither can be assigned to a single host in the traditional model. A /31 point-to-point link has no broadcast, and RFC 3021 allows both addresses to be used, which this page reflects.
What is a wildcard mask used for?
Cisco access control lists and OSPF use a wildcard mask, which is the bitwise inverse of the subnet mask. A zero bit means the corresponding address bit must match, and a one bit means it can be anything. For a /24 the wildcard mask is 0.0.0.255.
How do I tell whether two addresses are on the same subnet?
Compare their network addresses at the same prefix length. If the results are equal, they are in the same block. This page shows the network address, so run each address through it and compare.
Does this work with IPv6?
No. IPv6 uses 128-bit addresses and a different text format, and link-local and multicast rules change how the range is used. Use the IP address converter for IPv6 values. The arithmetic idea is the same, but the host ranges are far too large to list.