Subnet Masks in Binary Explained

Understand subnet masks through their binary representation. Learn how /24, /16, and variable-length masks work at the bit level for network segmentation.

CIDR / Dotted DecimalBinary (32-bit)Networking

Detailed Explanation

Subnet masks are 32-bit values where all the 1-bits are contiguous on the left and all the 0-bits are contiguous on the right. This structure divides an IP address into a network portion (1s) and a host portion (0s).

Common subnet masks in binary:

CIDR Decimal Binary Hosts
/8 255.0.0.0 11111111.00000000.00000000.00000000 16.7M
/16 255.255.0.0 11111111.11111111.00000000.00000000 65,534
/24 255.255.255.0 11111111.11111111.11111111.00000000 254
/25 255.255.255.128 11111111.11111111.11111111.10000000 126
/26 255.255.255.192 11111111.11111111.11111111.11000000 62
/27 255.255.255.224 11111111.11111111.11111111.11100000 30
/28 255.255.255.240 11111111.11111111.11111111.11110000 14
/30 255.255.255.252 11111111.11111111.11111111.11111100 2

How to calculate usable hosts:

The number of usable host addresses is 2^n - 2, where n is the number of 0-bits (host bits). We subtract 2 because the all-zeros address (network) and all-ones address (broadcast) are reserved.

Variable-length subnet masking (VLSM):

Modern networks use VLSM to allocate subnets of different sizes efficiently. By understanding binary subnet masks, you can carve a /24 network into smaller subnets: two /25s, four /26s, or a mix. For example, a company might use a /26 (62 hosts) for the main office, a /27 (30 hosts) for a branch, and a /30 (2 hosts) for point-to-point links.

The wildcard mask:

Cisco routers use wildcard masks, which are the bitwise inverse of subnet masks. A /24 subnet mask 255.255.255.0 has a wildcard of 0.0.0.255. In binary, every 1 becomes 0 and vice versa. Wildcard masks indicate which bits are "don't care" in access control lists.

Use Case

Cloud architects use binary subnet mask calculations to design VPC networks in AWS or Azure, ensuring each subnet has enough host addresses for current needs plus growth.

Try It — Number Base Converter

Open full tool