Subnet Masks Explained

Learning Objectives

Pre-Quiz: What a Mask Does

An IP address by itself tells you "who" a device is. What crucial piece of information does the subnet mask add?

The MAC (hardware) address of the device
Which bits identify the network versus the individual host
The speed of the physical link
The domain name that maps to the address

In a subnet mask, what does a bit set to 1 signify about the corresponding bit of the IP address?

That bit belongs to the host portion
That bit belongs to the network portion
That bit is always ignored by routers
That bit must be flipped before use

Which of the following is a valid subnet mask, given that masks must be contiguous?

11111111.00000000.11111111.00000000
11111111.11111111.11100000.00000000
10101010.11111111.00000000.00000000
00000000.11111111.11111111.11111111

Why are the mask 255.255.255.0 and the CIDR notation /24 considered two ways of writing the same fact?

Because 255 divided by 24 equals a whole number
Because /24 counts the 24 one-bits in the mask
Because both describe a wildcard mask
Because 24 is the number of usable hosts in the block

Why does the value 255 appear so often in subnet masks?

Because 255 is the largest IP address value allowed
Because 255 is a special reserved routing number
Because 255 is what an octet equals when all 8 of its bits are set to 1
Because 255 marks the broadcast address of every network

What a Mask Does

Key Points

A subnet mask partners with a 32-bit IPv4 address to answer one question: which bits identify the network, and which identify the individual host? Think of a postal address — "city and street" tells you the neighborhood (the network), while the "house number" identifies the specific building (the host). Wherever the mask has a 1, that address bit belongs to the network portion; wherever it has a 0, that bit belongs to the host portion. So for 192.168.10.50 with mask 255.255.255.0, the first three octets (192.168.10) are the network and the final octet (50) is the host.

Figure 4.1: How the mask splits an address into network and host portions

graph TD A["Subnet Mask: 255.255.255.0"] --> B["Mask bit = 1
(network side)"] A --> C["Mask bit = 0
(host side)"] B --> D["Network portion:
192.168.10"] C --> E["Host portion:
50"] D --> F["Identifies WHICH network
(the neighborhood)"] E --> G["Identifies WHICH host
(the specific building)"]

A valid mask must be contiguous: a solid run of 1-bits followed by a solid run of 0-bits, ones first, then zeros, with no interleaving. Because the 1s all come first, the boundary between network and host is a single point in the 32-bit string — a clean tear rather than a shredded strip. The bits must be contiguous, but they are not required to land on octet boundaries; that freedom is what makes masks like /26 (255.255.255.192) legal.

A mask is written just like an IP address — four dotted-decimal octets — but its meaning is clearest in binary. 255.255.255.0 expands to:

11111111.11111111.11111111.00000000

The 24 leading ones say "the first 24 bits are network"; the 8 trailing zeros say "the last 8 bits are host." That is exactly what CIDR captures as /24 — the prefix length is simply the count of 1-bits in the mask. The value 255 recurs because it is an octet with all eight bits set (128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255); a fully "host" octet reads as 0.

Visual animation — coming soon

Post-Quiz: What a Mask Does

An IP address by itself tells you "who" a device is. What crucial piece of information does the subnet mask add?

The MAC (hardware) address of the device
Which bits identify the network versus the individual host
The speed of the physical link
The domain name that maps to the address

In a subnet mask, what does a bit set to 1 signify about the corresponding bit of the IP address?

That bit belongs to the host portion
That bit belongs to the network portion
That bit is always ignored by routers
That bit must be flipped before use

Which of the following is a valid subnet mask, given that masks must be contiguous?

11111111.00000000.11111111.00000000
11111111.11111111.11100000.00000000
10101010.11111111.00000000.00000000
00000000.11111111.11111111.11111111

Why are the mask 255.255.255.0 and the CIDR notation /24 considered two ways of writing the same fact?

Because 255 divided by 24 equals a whole number
Because /24 counts the 24 one-bits in the mask
Because both describe a wildcard mask
Because 24 is the number of usable hosts in the block

Why does the value 255 appear so often in subnet masks?

Because 255 is the largest IP address value allowed
Because 255 is a special reserved routing number
Because 255 is what an octet equals when all 8 of its bits are set to 1
Because 255 marks the broadcast address of every network
Pre-Quiz: Common Subnet Masks

Why can you read the network/host split of 255.255.0.0 at a glance, without any binary math?

Because every /16 mask is memorized by routers automatically
Because each octet is either fully 255 (all network) or fully 0 (all host)
Because 255.255.0.0 has no host bits at all
Because the boundary always falls in the third octet

The last octet of a subnet mask shows the value 224. How many network bits are set within that octet?

2 bits
3 bits
4 bits
5 bits

A colleague writes a mask ending in the octet 200 (binary 11001000). Why is this mask invalid?

200 is larger than the maximum allowed octet value
Its bits are not contiguous — there is a 0 between 1s, so it is not a legal octet value
Only 255 and 0 are ever allowed in any mask octet
200 is reserved for wildcard masks only

Converting /26 to dotted decimal gives 255.255.255.192. Where does the 192 come from?

26 minus 8 equals 18, and 18 rounds to 192
Three octets use 24 bits, leaving 2 network bits in the fourth octet: 11000000 = 192
192 is 255 minus the prefix length of 26 plus 37
The fourth octet always equals 192 for any /25 through /30

The wildcard mask is the inverse of the subnet mask. What is the wildcard mask for 255.255.255.0, and how is it found?

0.0.0.255, by subtracting each mask octet from 255
255.255.255.255, by adding 255 to each octet
255.0.0.0, by reversing the octet order
0.0.0.0, because /24 has no don't-care bits

Common Subnet Masks

Key Points

Three masks show up constantly because they fall precisely on octet boundaries:

Because each octet is either fully 255 or fully 0, you read the split just by looking at which octets are 255 — no binary math needed. But the boundary is allowed to fall inside an octet, and then that octet shows a value other than 0 or 255. As network bits fill from the high (left) end, an octet can only ever take one of nine legal values:

Bits set (high end)Binary octetDecimal value
0000000000
110000000128
211000000192
311100000224
411110000240
511111000248
611111100252
711111110254
811111111255

These nine values let you translate quickly between a CIDR prefix and a mask. Worked example — /26: 26 network bits = 24 bits (three octets of 255) + 2 more bits in the fourth octet. Two high-end bits give 11000000 = 192, so /26 = 255.255.255.192. The final octet is neither 0 nor 255, yet the mask is perfectly valid.

The reference table below is one of the most-consulted tools in networking. It maps CIDR prefixes to their dotted-decimal mask, the inverse wildcard mask, the total addresses, and the usable hosts.

CIDRSubnet MaskWildcard MaskTotal AddressesUsable Hosts
/8255.0.0.00.255.255.25516,777,21616,777,214
/9255.128.0.00.127.255.2558,388,6088,388,606
/10255.192.0.00.63.255.2554,194,3044,194,302
/16255.255.0.00.0.255.25565,53665,534
/20255.255.240.00.0.15.2554,0964,094
/24255.255.255.00.0.0.255256254
/25255.255.255.1280.0.0.127128126
/26255.255.255.1920.0.0.636462
/27255.255.255.2240.0.0.313230
/28255.255.255.2400.0.0.151614
/29255.255.255.2480.0.0.786
/30255.255.255.2520.0.0.342

The wildcard mask is the bit-for-bit inverse of the subnet mask, found by subtracting each octet from 255. It looks identical on paper but carries the opposite meaning: in a subnet mask a 1 means "part of the network," while in a wildcard mask a 0 means "must match exactly" and a 1 means "don't care." Wildcard masks put their 0s at the beginning, so a larger CIDR prefix produces a smaller wildcard mask. They appear in Cisco ACLs and OSPF/EIGRP network statements — e.g. access-list 10 permit 192.168.1.0 0.0.0.255 matches all of 192.168.1.0/24. Unlike subnet masks, wildcard masks are not required to be contiguous, letting them match patterns like only odd or only even subnets.

Post-Quiz: Common Subnet Masks

Why can you read the network/host split of 255.255.0.0 at a glance, without any binary math?

Because every /16 mask is memorized by routers automatically
Because each octet is either fully 255 (all network) or fully 0 (all host)
Because 255.255.0.0 has no host bits at all
Because the boundary always falls in the third octet

The last octet of a subnet mask shows the value 224. How many network bits are set within that octet?

2 bits
3 bits
4 bits
5 bits

A colleague writes a mask ending in the octet 200 (binary 11001000). Why is this mask invalid?

200 is larger than the maximum allowed octet value
Its bits are not contiguous — there is a 0 between 1s, so it is not a legal octet value
Only 255 and 0 are ever allowed in any mask octet
200 is reserved for wildcard masks only

Converting /26 to dotted decimal gives 255.255.255.192. Where does the 192 come from?

26 minus 8 equals 18, and 18 rounds to 192
Three octets use 24 bits, leaving 2 network bits in the fourth octet: 11000000 = 192
192 is 255 minus the prefix length of 26 plus 37
The fourth octet always equals 192 for any /25 through /30

The wildcard mask is the inverse of the subnet mask. What is the wildcard mask for 255.255.255.0, and how is it found?

0.0.0.255, by subtracting each mask octet from 255
255.255.255.255, by adding 255 to each octet
255.0.0.0, by reversing the octet order
0.0.0.0, because /24 has no don't-care bits
Pre-Quiz: Applying the Mask

Which operation is applied between an IP address and its subnet mask to derive the network address?

Bitwise OR
Bitwise AND
Decimal addition
Bitwise XOR

In the AND operation, why do the network bits of the address survive unchanged while the host bits become 0?

AND-ing with 1 preserves a bit, while AND-ing with 0 clears it — and the mask is 1s over the network, 0s over the host
Because the router copies only the first three octets by convention
Because host bits are always physically zero in memory
Because AND randomly rounds host values down to 0

You AND 192.168.10.50 with 255.255.255.0. What network address results?

192.168.10.50
192.168.10.0
192.168.0.0
255.255.255.50

For a /24 network, how many usable hosts are available, and why is it not the full 256?

256, because every address in the block can be assigned
254, because the network address and broadcast address are reserved
255, because only the broadcast address is reserved
128, because half the block is reserved for future growth

A /30 is the classic choice for a point-to-point link between two routers. Why does it fit so well?

Because a /30 provides exactly 2 usable hosts — one for each end of the link
Because a /30 has no host bits, so no addresses are wasted
Because a /30 supports 254 usable hosts for future expansion
Because routers require the broadcast address to be usable

Applying the Mask

Key Points

The mask is applied through a bitwise AND: IP address AND subnet mask yields the network address. The AND truth table is 1&1=1, 1&0=0, 0&1=0, 0&0=0. The hidden pattern: AND-ing any bit with 1 preserves it, while AND-ing with 0 clears it to 0. Because the mask has 1s over the network portion and 0s over the host portion, the operation keeps the network bits exactly as they are and zeroes every host bit.

Worked example — 192.168.10.50 with 255.255.255.0:

IP address :  192.168.10.50   = 11000000.10101000.00001010.00110010
Subnet mask:  255.255.255.0   = 11111111.11111111.11111111.00000000
------------------------------  AND ---------------------------------
Network    :  192.168.10.0    = 11000000.10101000.00001010.00000000

In the first three octets the mask is all 1s, so 192, 168, and 10 pass through unchanged. In the fourth octet the mask is all 0s, so the host value 50 (00110010) is cleared to 0 — giving the network address 192.168.10.0. This is exactly how a router decides local vs. remote: every host that produces the same AND result is on the same subnet.

Figure 4.2: The bitwise AND process for deriving a network address

flowchart TD A["IP address
192.168.10.50"] --> C{"Bitwise AND
bit by bit"} B["Subnet mask
255.255.255.0"] --> C C --> D["Mask bit = 1
preserve the address bit"] C --> E["Mask bit = 0
clear the address bit to 0"] D --> F["Network bits kept:
192.168.10"] E --> G["Host bits zeroed:
.0"] F --> H["Network address
192.168.10.0"] G --> H

The leftover bits — everything the mask marked with a 0 — are the host portion. Overlaying the mask on the address makes the split obvious:

Address :  192 . 168 . 10 . 50
Mask    :  255 . 255 . 255 . 0
Role    :  NET   NET   NET   HOST

For non-octet-aligned masks the same overlay works at the bit level — the boundary just lands partway through an octet, splitting one octet into some network and some host bits.

The mask also dictates how many hosts a network can hold. Let n be the number of host bits, where n = 32 − prefix. Then total addresses = 2ⁿ and usable hosts = 2ⁿ − 2. The "minus 2" reserves the all-zeros host address (the network address) and the all-ones host address (the broadcast address).

Figure 4.3: Deriving host capacity from the prefix

flowchart LR A["Prefix length
e.g. /24"] --> B["Host bits
n = 32 − prefix"] B --> C["Total addresses
2^n"] C --> D["Subtract 2:
network + broadcast"] D --> E["Usable hosts
2^n − 2"]

Worked example — a /24: n = 32 − 24 = 8 host bits, so 2⁸ = 256 total and 256 − 2 = 254 usable — matching the reference table. The point-to-point case — a /30: n = 32 − 30 = 2 host bits, so 2² = 4 total and only 4 − 2 = 2 usable, exactly what a router-to-router link needs (one address per end). The design lesson: the more network bits you commit, the fewer host bits remain, so choosing a mask is always a trade-off between number of subnets and hosts per subnet — the tension that VLSM later resolves.

Visual animation — coming soon

Post-Quiz: Applying the Mask

Which operation is applied between an IP address and its subnet mask to derive the network address?

Bitwise OR
Bitwise AND
Decimal addition
Bitwise XOR

In the AND operation, why do the network bits of the address survive unchanged while the host bits become 0?

AND-ing with 1 preserves a bit, while AND-ing with 0 clears it — and the mask is 1s over the network, 0s over the host
Because the router copies only the first three octets by convention
Because host bits are always physically zero in memory
Because AND randomly rounds host values down to 0

You AND 192.168.10.50 with 255.255.255.0. What network address results?

192.168.10.50
192.168.10.0
192.168.0.0
255.255.255.50

For a /24 network, how many usable hosts are available, and why is it not the full 256?

256, because every address in the block can be assigned
254, because the network address and broadcast address are reserved
255, because only the broadcast address is reserved
128, because half the block is reserved for future growth

A /30 is the classic choice for a point-to-point link between two routers. Why does it fit so well?

Because a /30 provides exactly 2 usable hosts — one for each end of the link
Because a /30 has no host bits, so no addresses are wasted
Because a /30 supports 254 usable hosts for future expansion
Because routers require the broadcast address to be usable

Your Progress

Answer Explanations