How to find the subnet mask of an IP address
An IP address on its own doesn't tell you its subnet mask — the mask (or its
shorthand, the CIDR prefix like /24) has to come from somewhere else:
it's assigned alongside the address, either by whoever configured the network or by
documentation like a router's DHCP settings. Once you know the prefix length, the
subnet mask follows directly: it's a run of that many 1 bits from the left,
followed by 0 bits to fill out the remaining length (32 bits for IPv4, 128 for
IPv6). A /24 means 24 one-bits followed by 8 zero-bits, which written
out in IPv4's dotted-decimal form is 255.255.255.0. Enter your address
and prefix above and the calculator does that conversion instantly, in either
direction.
Common IPv4 CIDR prefixes
| CIDR | Subnet Mask | Usable Hosts |
|---|---|---|
| /24 | 255.255.255.0 | 254 |
| /25 | 255.255.255.128 | 126 |
| /26 | 255.255.255.192 | 62 |
| /27 | 255.255.255.224 | 30 |
| /28 | 255.255.255.240 | 14 |
| /29 | 255.255.255.248 | 6 |
| /30 | 255.255.255.252 | 2 |
| /31 | 255.255.255.254 | 2* |
| /32 | 255.255.255.255 | 1* |
IPv4 vs. IPv6 subnetting
IPv4 subnets have a network address, a broadcast address, and a range of usable addresses in between (the network and broadcast addresses themselves aren't assignable to a host, except in the special case of a /31 point-to-point link). IPv6 has no broadcast address; multicast is used instead. The calculator therefore shows the first and last address in the subnet rather than a traditional broadcast/usable-host range. IPv6 subnets are also almost always vastly larger than anything used in IPv4; a standard /64 contains 18,446,744,073,709,551,616 addresses on its own.
Frequently asked questions
How do you find the subnet mask of an IP address?
You need the CIDR prefix length (like /24) alongside the address, since the mask isn't derivable from the address alone. Once you have the prefix, the mask is that many 1 bits followed by 0 bits — /24 becomes 255.255.255.0 in IPv4's dotted-decimal notation.
What is the difference between a network address and a broadcast address?
The network address is the first address in a subnet (all host bits set to 0), used to identify the subnet itself. The broadcast address is the last (all host bits set to 1), used to send a message to every host on that subnet at once. In traditional IPv4 subnets, neither is normally assigned to an individual host. A /31 point-to-point subnet is a special case where both addresses can be used.
Does IPv6 have a broadcast address?
No. IPv6 does not have a broadcast address. It uses multicast instead. Unlike traditional IPv4 subnetting, IPv6 does not reserve a network address and broadcast address from each subnet as a general rule.
What is a /30 subnet mask?
A /30 IPv4 prefix has the subnet mask 255.255.255.252. It provides 4 total addresses: one network address, two traditionally usable host addresses, and one broadcast address. For example, 192.168.1.0/30 contains 192.168.1.0 through 192.168.1.3.
How many usable hosts are in a /24 subnet?
A /24 IPv4 subnet has 256 total addresses and 254 traditionally usable host addresses. The network address and broadcast address account for the two addresses that aren't normally assigned to hosts.