Subnetting 101
Step 3 — Subnet Masks
The subnet mask is what tells a device which part of an IP address is the network and which part is the host. Master this, and subnetting becomes intuitive.
What is a Subnet Mask?
A subnet mask is a 32-bit number that "masks" the IP address to reveal the network portion. It's written the same way as an IP address:
In binary, a subnet mask is a series of 1s followed by 0s. The 1s mark the network bits, the 0s mark the host bits.
The Binary View
Here's 255.255.255.0 in binary:
| Octet | Decimal | Binary |
|---|---|---|
| 1st | 255 | 11111111 |
| 2nd | 255 | 11111111 |
| 3rd | 255 | 11111111 |
| 4th | 0 | 00000000 |
24 network bits (1s) + 8 host bits (0s) = 32 total bits
Common Subnet Masks
You need to memorize these. They appear constantly in networking:
| Decimal | Binary | Network Bits |
|---|---|---|
| 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 |
The Magic Numbers
Notice that subnet mask octets only use specific values. These are the only valid numbers in a subnet mask:
Each represents a valid boundary for the network/host split
| Decimal | Binary | Network Bits | Host Bits |
|---|---|---|---|
| 0 | 00000000 | 0 | 8 |
| 128 | 10000000 | 1 | 7 |
| 192 | 11000000 | 2 | 6 |
| 224 | 11100000 | 3 | 5 |
| 240 | 11110000 | 4 | 4 |
| 248 | 11111000 | 5 | 3 |
| 252 | 11111100 | 6 | 2 |
| 254 | 11111110 | 7 | 1 |
| 255 | 11111111 | 8 | 0 |
How Masking Works (AND Operation)
When a device applies a subnet mask, it performs a bitwise AND operation. Anywhere the mask has a 1, the IP bit is preserved. Anywhere it's 0, the result is 0.
The result (192.168.1.0) is the network address. The host bits become all zeros.
Practice Exercises
Store your answers
Inputs start empty. Click “Check answers” when you're ready.
Saved locally in your browser for this device.
- 255.255.255.192 in binary
- How many network bits does 255.255.240.0 have?
- A mask has 25 network bits. What is it in decimal?
- 10.50.100.200 with 255.255.255.0 — what is the network address?
Show Answers
Use the Check answers button in the exercise box above to reveal correct answers after you attempt them.
Checkpoint
Before moving on, make sure you can:
- Convert any subnet mask to binary
- Count network bits from a subnet mask
- Recognize the "magic numbers" (0, 128, 192, 224, 240, 248, 252, 254, 255)
- Apply a subnet mask to find the network address