Subnet Mask Calculator
Convert prefix lengths (/24) to subnet masks and vice versa. Includes wildcard mask, hex, binary, and host count. Full /0–/32 reference table.
255.255.255.0/240.0.0.2550xFFFFFF000x000000FF11111111.11111111.11111111.00000000256254Subnet mask reference
How Subnet Masks Work (Bitwise AND Logic)
In TCP/IP networking, an IPv4 address is split into two parts: the Network ID (which identifies the network or broadcast domain) and the Host ID (which identifies the specific device on that network).
A Subnet Mask is a 32-bit filter that tells routers and host operating systems where the network portion ends and the host portion begins. When a computer needs to send a packet, it executes a hardware-level bitwise AND operation:
| Component | Dotted Decimal | Binary Representation |
|---|---|---|
| Host IP Address | 192.168.1.55 | 11000000 . 10101000 . 00000001 . 00110111 |
| Subnet Mask (/24) | 255.255.255.0 | 11111111 . 11111111 . 11111111 . 00000000 |
| Network ID (Bitwise AND) | 192.168.1.0 | 11000000 . 10101000 . 00000001 . 00000000 |
Complete IPv4 Subnet Mask Reference Table (/8 to /32)
The reference table below lists standard IPv4 subnet masks, corresponding wildcard masks, total address space, and usable host counts:
| CIDR | Subnet Mask | Wildcard Mask | Total IPs | Usable Hosts | Common Deployment |
|---|---|---|---|---|---|
/8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 | Class A, Large enterprise / Carrier NAT |
/16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 | Class B, Cloud VPC networks (AWS/GCP) |
/20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 | VPC Availability Zone blocks |
/24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 | Standard LAN, Office Wi-Fi, Cloud public subnet |
/25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 | Departmental network split |
/26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 | Server rack cluster / Database tier |
/27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 | Kubernetes worker node pool |
/28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 | Small DMZ, Management VLAN |
/29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 | ISP public IP pool (HA firewall pair) |
/30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 | Traditional point-to-point router links |
/31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 | RFC 3021 modern point-to-point router links |
/32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 | Single host route, Loopback interface |
Frequently Asked Questions
What is the difference between a CIDR prefix and a subnet mask?
A CIDR prefix (such as /24) represents the count of leading 1-bits that identify the network portion of an IP address. A subnet mask is the 32-bit dotted-decimal representation of those same bits (e.g., 255.255.255.0). Both express the exact same network boundary.
How do you calculate the number of usable hosts from a subnet mask?
Subtract the CIDR prefix length from 32 to determine the number of host bits (H = 32 - Prefix). The total addresses is 2^H. For standard subnets (/1 to /30), subtract 2 (one for network ID, one for broadcast): Usable Hosts = 2^H - 2. For /24: H = 8, so 2^8 - 2 = 254 usable hosts.
Why does a /31 subnet have 2 usable hosts instead of zero?
Under RFC 3021 ("Using 31-Bit Prefixes on IPv4 Point-to-Point Links"), routers can use /31 subnets for point-to-point links without allocating separate network and broadcast addresses. Both addresses (host 0 and host 1) are treated as usable interface addresses, eliminating wasted IPv4 space.
What is a wildcard mask and how is it derived from a subnet mask?
A wildcard mask is the bitwise inverse of a subnet mask, used primarily in Cisco ACLs and OSPF configurations. In a wildcard mask, 0 means "must match" and 1 means "ignore". You compute it by subtracting each octet of the subnet mask from 255 (e.g., 255.255.255.255 - 255.255.255.0 = 0.0.0.255).
How does a network device use a subnet mask to route packets?
When a host transmits a packet to a destination IP, it performs a bitwise AND operation between its own subnet mask and the destination IP. If the result matches the local network ID, the packet is delivered directly via ARP. If the result differs, the packet is forwarded to the default gateway router.