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.

Subnet mask255.255.255.0
Prefix length/24
Wildcard mask0.0.0.255
Mask (hex)0xFFFFFF00
Wildcard (hex)0x000000FF
Binary11111111.11111111.11111111.00000000
Total IPs256
Usable hosts254

Subnet mask reference

PrefixSubnet maskWildcardUsable hosts

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:

ComponentDotted DecimalBinary Representation
Host IP Address192.168.1.5511000000 . 10101000 . 00000001 . 00110111
Subnet Mask (/24)255.255.255.011111111 . 11111111 . 11111111 . 00000000
Network ID (Bitwise AND)192.168.1.011000000 . 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:

CIDRSubnet MaskWildcard MaskTotal IPsUsable HostsCommon Deployment
/8255.0.0.00.255.255.25516,777,21616,777,214Class A, Large enterprise / Carrier NAT
/16255.255.0.00.0.255.25565,53665,534Class B, Cloud VPC networks (AWS/GCP)
/20255.255.240.00.0.15.2554,0964,094VPC Availability Zone blocks
/24255.255.255.00.0.0.255256254Standard LAN, Office Wi-Fi, Cloud public subnet
/25255.255.255.1280.0.0.127128126Departmental network split
/26255.255.255.1920.0.0.636462Server rack cluster / Database tier
/27255.255.255.2240.0.0.313230Kubernetes worker node pool
/28255.255.255.2400.0.0.151614Small DMZ, Management VLAN
/29255.255.255.2480.0.0.786ISP public IP pool (HA firewall pair)
/30255.255.255.2520.0.0.342Traditional point-to-point router links
/31255.255.255.2540.0.0.122RFC 3021 modern point-to-point router links
/32255.255.255.2550.0.0.011Single 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.