NetworkTools
Sign In
1What is Subnetting?2CIDR Notation3Subnet Masks4Network, Broadcast & Hosts5/24 Subnets6/25 through /30 Subnets7Third Octet Subnets8Subnetting Practice
← Back to Subnetting Mastery

Learning Objectives

  • Understand what a subnet mask does
  • Convert between decimal and binary masks
  • Use the subnet mask to identify networks

What Is a Subnet Mask?

A subnet mask is a 32-bit number that separates the network portion of an IP address from the host portion. Bits set to 1 represent the network; bits set to 0 represent the host.

255.255.255.0 in binary:

11111111.11111111.11111111.00000000

The 1s mean "this part identifies the network." The 0s mean "this part identifies the host."

How It Works

When a device wants to know if another device is on the same network, it performs a bitwise AND between its own IP and subnet mask, and compares it to the same operation on the destination IP. If the results match, they're on the same network.

For example, with IP 192.168.1.100 and mask 255.255.255.0:

    192.168.1.100  →  11000000.10101000.00000001.01100100
AND 255.255.255.0  →  11111111.11111111.11111111.00000000
    ───────────────────────────────────────────────────────
                    11000000.10101000.00000001.00000000
                    → 192.168.1.0 (network address)

Common Subnet Masks

Decimal | Binary | Prefix --------|--------|------- 255.0.0.0 | 11111111.00000000.00000000.00000000 | /8 255.255.0.0 | 11111111.11111111.00000000.00000000 | /16 255.255.255.0 | 11111111.11111111.11111111.00000000 | /24 255.255.255.128 | 11111111.11111111.11111111.10000000 | /25 255.255.255.192 | 11111111.11111111.11111111.11000000 | /26 255.255.255.224 | 11111111.11111111.11111111.11100000 | /27 255.255.255.240 | 11111111.11111111.11111111.11110000 | /28 255.255.255.248 | 11111111.11111111.11111111.11111000 | /29 255.255.255.252 | 11111111.11111111.11111111.11111100 | /30

Converting Between Prefix and Mask

To convert a prefix to a mask:

  1. Write 1 for each bit of the prefix
  2. Write 0 for the remaining bits
  3. Group into 8-bit octets and convert to decimal

For /27: 27 ones + 5 zeros

11111111.11111111.11111111.11100000
= 255.255.255.224

What is the subnet mask for /29?

How many bits are set to 1 in the subnet mask 255.255.255.192?

Key Takeaways

  • Subnet mask uses 1s for network bits, 0s for host bits
  • Bitwise AND of IP and mask gives the network address
  • Every prefix length has exactly one subnet mask
  • Mastery comes from knowing the mask instantly from the prefix

Next lesson: network addresses, broadcast addresses, and hosts.

PreviousCIDR NotationNextNetwork, Broadcast & Hosts