AP Networking • IPv4 • Subnetting

Subnet Mask Explained

Understand the mask as a forwarding decision tool: convert dotted decimal to CIDR, derive the network with bitwise AND, predict local-vs-remote behavior, and troubleshoot wrong-mask symptoms using real network evidence.

Independent AP Networking resource • Updated 2026-09-12 • Includes 24 free digital flashcards
Subnet-mask rule: the mask decides whether the host sends directly or uses its gateway.
Practice with Flashcards
Definition

A subnet mask is the host's local-versus-remote decision boundary

An IPv4 subnet mask is a 32-bit value paired with an IPv4 address. In normal CIDR subnetting, the mask begins with contiguous 1 bits and ends with 0 bits. The 1s identify the network prefix; the 0s identify host space. That boundary determines whether the host tries to deliver directly on the local link or sends the traffic to its default gateway.

Core reasoning chain: IP + mask → network prefix → compare destination → local or remote → ARP for destination or gateway.
Valid mask octets

The familiar decimal values come directly from leading binary 1s

A partial mask octet can contain only leading 1s followed by 0s in standard CIDR. That produces 128, 192, 224, 240, 248, 252, and 254.

BinaryDecimalPrefix bits in octet
100000001281
110000001922
111000002243
111100002404
111110002485
111111002526
111111102547
111111112558

Swipe horizontally to see the mask table.

CIDR conversion

Count the 1 bits to convert dotted decimal to prefix length

255.255.255.0 is /24 because the mask contains 24 leading 1s. 255.255.255.192 is /26. 255.255.248.0 is /21.

/24

255.255.255.0
8 host bits

/26

255.255.255.192
6 host bits

/21

255.255.248.0
11 host bits

Bitwise AND

A host derives the network by ANDing the address with the mask

Bitwise AND preserves a bit only when both input bits are 1. Because host positions in the mask are 0, those positions become 0 in the network result.

IP: 192.168.12.77 Mask: 255.255.255.192 (/26) Fourth octet: 77 = 01001101 192 = 11000000 AND = 01000000 = 64 Network: 192.168.12.64/26

This is the mathematical reason the host can identify its own subnet.

Local or remote

The mask decides whether the destination is delivered directly or sent to the gateway

The host applies the prefix to its own address and to the destination. Matching prefixes mean local delivery. Different prefixes mean the host normally uses its default gateway.

Host: 192.168.12.77/26 Destination: 192.168.12.90 → local Destination: 192.168.12.140 → remote → use gateway
Mask vs gateway

The mask and gateway solve different parts of the forwarding decision

Mask

Is the destination local or remote?

Gateway

Where should remote traffic go next?

ARP

Which local MAC should receive the frame?

A correct gateway cannot compensate for a wrong mask if the host never decides to use the gateway.

Wrong mask: too broad

A too-broad mask can make a remote destination look local

Suppose 10.10.10.50 should use /24 but is configured /16. The host now thinks 10.10.20.8 is local and tries to ARP for it directly.

Correct /24: 10.10.20.8 → remote use gateway Wrong /16: 10.10.20.8 → appears local ARP directly

If there is no local Layer 2 path to that address, communication fails even though the gateway itself may be healthy.

Wrong mask: too narrow

A too-narrow mask can make a local destination look remote

The opposite error sends traffic toward the gateway even when the destination really belongs on the local link. Depending on the router and network design, that traffic may be rejected or handled inefficiently.

High-information clue: wrong masks often create selective failures because only some destinations cross the mistaken boundary.
Same IP, different prefix

The same host address can belong to very different local ranges

Take 192.168.50.130. Under /24, it is in 192.168.50.0/24. Under /26, it is in 192.168.50.128/26. Under /27, it is in 192.168.50.128/27.

Address/prefixNetworkTraditional broadcast
192.168.50.130/24192.168.50.0192.168.50.255
192.168.50.130/26192.168.50.128192.168.50.191
192.168.50.130/27192.168.50.128192.168.50.159

Swipe horizontally to compare prefixes.

Block size

256 minus the interesting mask octet gives the subnet block size

For /26, the mask octet is 192, so the block size is 64. For /27, 256 − 224 = 32. These boundaries let you find the network without writing every bit.

/26 → 64 boundaries: 0, 64, 128, 192 /27 → 32 boundaries: 0, 32, 64, 96, 128, 160...
Host bits and capacity

Prefix length also controls the number of addresses in the subnet

Host bits equal 32 minus the prefix length. A /26 leaves 6 host bits and therefore contains 64 total addresses. A /29 leaves 3 host bits and contains 8 total addresses.

PrefixMaskHost bitsTotal addresses
/24255.255.255.08256
/25255.255.255.1287128
/26255.255.255.192664
/27255.255.255.224532
/28255.255.255.240416
/29255.255.255.24838
/30255.255.255.25224

Swipe horizontally to see address counts.

Earlier-octet subnetting

The interesting octet can be the third octet or earlier

A /20 is 255.255.240.0, so the third-octet block size is 16. A /22 is 255.255.252.0, so the block size is 4.

172.16.45.10/20 Third-octet boundaries: 0, 16, 32, 48... 45 lies in 32-47 Network: 172.16.32.0/20
Gateway validity

The gateway normally has to be reachable as a local next hop

If the client is 192.168.40.130/26, then 192.168.40.129 is local while 192.168.40.1 is not. The host must be able to resolve the gateway locally before it can use that router as its first hop.

Fast check: calculate the local subnet before accepting the configured gateway as valid.
ARP behavior

The mask determines whether ARP targets the destination or the gateway

If the destination is local, the host ARPs for the destination itself. If the destination is remote, the host ARPs for the gateway. A wrong mask can therefore make the host ARP for the wrong target.

Local destination: ARP for destination IP Remote destination: ARP for gateway IP Wrong mask: may choose the wrong ARP target
DHCP interaction

A client can receive an IP address and still be on the wrong subnet

DHCP often supplies the address, mask, gateway, and DNS information. If a client is placed in the wrong VLAN or reaches the wrong DHCP scope, it can receive a complete-looking configuration that is wrong for the intended network.

Known-good comparison: compare address range, prefix, gateway, DNS, and VLAN with a peer that works.
Route-table interaction

The mask creates the connected route that shapes every later forwarding decision

Configuring an address and mask normally creates an on-link route for the local subnet. A wrong mask changes that connected route and therefore changes which destinations bypass the default route.

Host: 192.168.12.77/26 Connected: 192.168.12.64/26 on-link Default: 0.0.0.0/0 via 192.168.12.65
Worked case 1

Remote address is incorrectly treated as local

Observed: 10.10.10.50/16 ARPs directly for 10.10.20.8.

Interpretation: under /16, the host believes 10.10.20.8 is local. If the intended design is /24, the mask is too broad.

Worked case 2

The gateway sits outside the client's actual subnet

Observed: 192.168.40.130/26 uses gateway 192.168.40.1.

Interpretation: the client belongs to 192.168.40.128/26, so .1 is outside the normal local range. Fix the addressing plan before blaming upstream routing.

Worked case 3

The client receives the wrong DHCP scope

Observed: neighboring clients use 10.20.30.0/24, but one client receives 10.20.40.0/24 with gateway 10.20.40.1.

Interpretation: the client may be in the wrong VLAN or DHCP scope even though its own mask and gateway are internally consistent.

Worked case 4

Only some destinations fail after a mask change

Observed: nearby hosts work, but destinations across the intended subnet boundary fail.

★ Addressing Practice • Subnet Mask Explained

A five-minute warm-up for Subnet Mask Explained

Tomorrow’s opening question can pick up where this page leaves off: have students explain where the addresses come from and what they would check when a device cannot connect. The 300 Bell Ringers give you short questions and teacher answers you can use without preparing a new starter each morning.

300 AP Networking Bell Ringers
$74.99
BUY TEACHER PACK → See what is included in the 300 Bell Ringers →
Instant Access • Full-Year Teacher Resource

Interpretation: compare the configured prefix to the design. A wrong mask creates selective local-vs-remote misclassification rather than necessarily breaking every destination.

Troubleshooting matrix

Use subnet-mask evidence to select the next artifact

EvidenceInterpretationNext artifact
APIPAExpected DHCP configuration missingDHCP/VLAN path
Gateway outside subnetAddressing plan invalidIP/prefix/gateway config
ARP for remote hostHost thinks destination is localMask and route table
Correct subnet, gateway ARP failsLayer 2/gateway issueARP/MAC/VLAN/SVI
Gateway works, remote IP failsMove upstreamRoute/NAT/WAN/firewall

Swipe horizontally to see the troubleshooting matrix.

Exam method

Use the same sequence on every subnet-mask scenario

1. Read IP + prefix 2. Derive local subnet 3. Derive destination subnet 4. Decide local or remote 5. Predict ARP target: destination or gateway 6. Verify with the relevant artifact

This order prevents visual guesswork from decimal addresses.

Addressing & Subnetting Lab • 120 Missions

Let students try Subnet Mask Explained for themselves

Reading the explanation is a start. In the browser simulator, students work through a broken network, choose what to test and see whether their fix worked. It gives them another chance to use what they learned about Subnet Mask Explained.

AP Networking Browser Troubleshooting Simulator
$29.99
120 Missions • 60 Failure Patterns • Offline Copy
GET THE SIMULATOR → See all 120 missions & features
Common traps

Seven subnet-mask mistakes to avoid

Binary intuition

The subnet mask is easiest to trust when you can see the network bits stay fixed

Take 192.168.12.77/26. A /26 means the first 26 bits belong to the network and the final 6 bits belong to the host. In the fourth octet, the mask is 11000000. That means only the first two bits of the fourth octet are part of the network. Every address whose fourth octet begins with those same two network bits belongs to the same /26 block.

Fourth octet of host 77: 01001101 /26 mask: 11000000 Network bits: 01------ Possible host-bit range: 01000000 through 01111111 64 through 127 Therefore: 192.168.12.77/26 belongs to 192.168.12.64/26

This is why /26 boundaries fall at 0, 64, 128, and 192. The decimal block pattern is just a compact way of representing the binary boundary.

Local-delivery comparison

Two addresses can look close in decimal and still require the gateway

Visual similarity is not enough. A client at 192.168.12.77/26 and a server at 192.168.12.140/26 share the first three octets, but they are in different /26 networks. The client is in 192.168.12.64/26; the server is in 192.168.12.128/26.

Addressing Exam Practice • Subnet Mask Explained

Check whether Subnet Mask Explained has really stuck

Once students have worked through this topic, give them questions mixed in with the rest of the course. The Exam Prep Vault includes practice exams, multiple-choice questions and artifact labs so they cannot rely on a chapter heading to tell them what to do.

AP Networking Complete Exam Prep Vault
$39.99
GET THE EXAM PREP VAULT → See the Exam Prep Vault contents →
4 Practice Exams • 320 MCQs • 60 Artifact Labs
Expected behavior: the client should not ARP directly for 192.168.12.140. It should ARP for its default gateway and send the frame there for routing.

This is one of the most useful exam distinctions because it prevents the common mistake of treating “same first three octets” as proof of local delivery.

Known-good peer method

Compare a failing client with a working client before changing the network

When a subnet-mask problem is suspected, compare the failing endpoint with a known-good device that should be in the same VLAN. Check the IP range, prefix length, gateway, DNS values, and route table. If the working device has /24 and the failing device has /16, that difference is high-information evidence.

Premium Routing Feedback

Spend less time marking explanations about Subnet Mask Explained

When students explain their answer, it takes more than a right-or-wrong check to see what they understand. The Grading Copilot helps you review how they used the clues, where their explanation falls short and what feedback to give next. You make the final grading decision.

AP Networking Artifact Analysis Grading Copilot
$49.99
8 Criteria • 5 Task Modes • Offline Premium Copy
GET THE GRADING COPILOT → See the free Copilot preview
Working client: 10.10.10.44/24 gateway 10.10.10.1 Failing client: 10.10.10.50/16 gateway 10.10.10.1 Destination: 10.10.20.8 Working client: remote → gateway Failing client: appears local → ARP directly

The gateway value is identical, yet behavior differs because the mask controls whether the gateway is used at all.

Packet-capture view

A capture can prove the host's local-versus-remote decision

If a client is trying to reach a destination that should be remote, capture the first packets. Repeated ARP requests for the destination itself indicate that the host believes the destination is local. ARP requests for the gateway indicate that the host believes the destination is remote.

Expected remote behavior: ARP who-has 10.10.10.1 then send IP packet to gateway MAC Wrong-mask behavior: ARP who-has 10.10.20.8 repeatedly no reply

This turns subnetting from abstract arithmetic into visible packet behavior. It also gives you a way to distinguish a wrong-mask decision from a later routing or firewall failure.

NEW • COMPLETE 180-DAY TEACHER CURRICULUM

Teach Subnet Mask Explained as part of a planned school year

This page gives you one topic. The 180-Day Teacher Curriculum puts it into a full course plan, with daily teaching notes, student activities and checks for understanding. Use it when you need to know what comes before this lesson and what to teach next.

AP Networking Complete 180-Day Teacher Curriculum
$199.99
180 Lessons • 180 Daily Simulators • 36 Teaching Weeks
GET THE 180-DAY CURRICULUM → See 3 free curriculum examples
Capstone scenario

Use mask, gateway, ARP, and route evidence together

A workstation is configured as 172.20.18.70/20 with gateway 172.20.16.1. It can reach devices in the 172.20.16.0–31.255 range but fails to reach 172.20.40.10. That behavior is expected: /20 creates 16-value blocks in the third octet. The local network for 18 is 172.20.16.0/20; 40 belongs to a different block.

Client: 172.20.18.70/20 Mask: 255.255.240.0 Local third-octet block: 16 - 31 Gateway: 172.20.16.1 local ✓ Destination: 172.20.40.10 remote ✓ Expected ARP target: 172.20.16.1 not 172.20.40.10

If the capture instead shows ARP requests for 172.20.40.10, the configured mask is not actually /20 or another local route is influencing the decision. That is the level of reasoning a strong subnet-mask answer should reach: calculate the boundary, predict the forwarding behavior, then verify it with evidence.

Free digital flashcards

24 Subnet Mask digital flashcards

Practice CIDR conversion, binary mask values, bitwise AND, local-vs-remote behavior, wrong-mask symptoms, common masks, gateway validity, ARP decisions, and troubleshooting.

All subnet-mask cards
Click or press Enter/Space to reveal.
Always connect the mask to local-vs-remote behavior.
0 seen•24 cards
Continue studying

Connect subnet masks to host ranges, broadcasts, and troubleshooting