What Is a Subnet Calculator?
A subnet calculator takes an IPv4 address and a CIDR prefix (like 192.168.1.10/24) and instantly works out the network address, subnet mask, broadcast address, the range of usable host addresses, and the total number of hosts the subnet can hold. It is an essential tool for network engineers, sysadmins, and students learning how IP addressing and subnetting work. This tool applies to standard IPv4 addressing and is universal — it is not specific to any country or vendor.
How to Use It
Enter the four octets of your IPv4 address (each 0–255) and choose a prefix length between 0 and 32. Click calculate to see the subnet mask, network address, first and last usable host, broadcast address, and the usable host count. A /24 network, for example, gives you 256 total addresses and 254 usable hosts.
The Formula Explained
The subnet mask is built by shifting all ones left by the number of host bits: \(\text{Mask} = (\text{0xFFFFFFFF} \ll (32 - \text{Prefix})) \mathbin{\&} \text{0xFFFFFFFF}\). The network address is the bitwise AND of the IP and the mask: \(\text{Network} = \text{IP} \mathbin{\&} \text{Mask}\). The broadcast address sets every host bit to one: \(\text{Broadcast} = \text{Network} \mathbin{|} \lnot\,\text{Mask}\). The number of usable hosts is \(2^{\,32 - \text{Prefix}} - 2\), where we subtract the network and broadcast addresses. For /31 and /32 there are no usable hosts under classic rules, so the count is shown as 0.
$$\begin{gathered} \text{Total} = 2^{\,32 - \text{Prefix}}, \qquad \text{Usable} = 2^{\,32 - \text{Prefix}} - 2 \\[1.5em] \text{where}\quad \left\{ \begin{aligned} \text{IP} &= \text{Oct1} \cdot 2^{24} + \text{Oct2} \cdot 2^{16} + \text{Oct3} \cdot 2^{8} + \text{Oct4} \\ \text{Mask} &= \big(\text{0xFFFFFFFF} \ll (32 - \text{Prefix})\big) \\ \text{Network} &= \text{IP} \mathbin{\&} \text{Mask} \\ \text{Broadcast} &= \text{Network} \mathbin{|} \lnot\,\text{Mask} \end{aligned} \right. \end{gathered}$$
Worked Example
For 192.168.1.10/24: host bits = \(32 - 24 = 8\). Mask = 255.255.255.0. Network = 192.168.1.0. Broadcast = 192.168.1.255. Usable hosts = \(2^8 - 2 = 254\), ranging from 192.168.1.1 to 192.168.1.254.
FAQ
Why subtract 2 from the host count? The first address in a subnet is reserved as the network identifier and the last is the broadcast address, so neither can be assigned to a device.
What does /24 mean? The prefix /24 means the first 24 bits identify the network and the remaining 8 bits are available for hosts, equivalent to a 255.255.255.0 mask.
Does this support IPv6? No — this calculator covers IPv4 addressing only. IPv6 uses a 128-bit address space and different conventions.