Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

Subnet mask

Direct answer

A subnet mask is the 32-bit dotted form of the prefix length — 1s for network bits, 0s for host bits — for example 255.255.255.192 for /26.

When to use this

Use it to convert between prefix length and dotted mask, and to spot a host or interface with the wrong mask.

First 30 seconds

1. Compare the mask on the host and on the gateway — identical?

2. Convert: /26 = 255.255.255.192.

3. Host mask too large (/16 instead of /24) → it ARPs for remote addresses directly.

4. Too small → it sends local traffic to the gateway.

5. Fix in DHCP or the static configuration.

Operational verification

prefix length → dotted mask → same mask on all hosts and the gateway in the subnet → correct local/remote decisions

Context & applicabilityCommon mistakes · platform/version boundaries
Common mistakes
Mask vs wildcard mistakes
  • Using a subnet mask in an ACL or OSPF network statement where a wildcard is required (255.255.255.0 vs 0.0.0.255).
  • Non-contiguous masks (e.g. 255.255.0.255) are invalid for subnets.
  • Entering /24 on a device that expects a dotted mask — check the syntax per platform.
Platform / version applicability
Protocol standard + deployed implementation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformProtocol standard
Key commandshow ip interface Gi0/0 | include Internet address
Scope / prerequisiteUse it to convert between prefix length and dotted mask, and to spot a host or interface with the wrong mask.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

1 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Commands Verify boundary
show ip interface Gi0/0 | include Internet address
ipconfig                                     # Windows: Subnet Mask
ip -4 addr show eth0                         # Linux: /prefix
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Command lookup Jump straight to Cisco syntax
Key points

Mask octet values: 128 (/25), 192 (/26), 224 (/27), 240 (/28), 248 (/29), 252 (/30), 254 (/31), 255. A wildcard mask (ACLs, OSPF) is the inverse: 255.255.255.255 minus the mask. A wrong mask on one host makes it treat neighbours as remote or remote hosts as local.

Key checks
  • show ip interface brief — addresses on each interface.
  • show ip interface <if> | include Internet address — address with prefix length.
  • show ip route connected — the subnets the router derives from its addresses.
  • show ip route <prefix> longer-prefixes — overlapping or more specific routes.
  • Subnet calculator (e.g. ipcalc <ip>/<len> on Linux) — network, broadcast and host range.
ReferenceWhat it is1 section · depth on demand

How it works

The subnet mask marks which bits of the address are network (1) and which are host (0). Valid masks are contiguous ones followed by zeros, so each octet can only be 0, 128, 192, 224, 240, 248, 252, 254 or 255. The block size in the interesting octet is 256 − mask value (mask 224 → blocks of 32).

ReferenceImportant terms & boundaries3 sections · depth on demand

Quick conversions

PrefixMaskWildcardHosts
/24255.255.255.00.0.0.255254
/25255.255.255.1280.0.0.127126
/27255.255.255.2240.0.0.3130
/29255.255.255.2480.0.0.76
/30255.255.255.2520.0.0.32

In depth

The AND operation, bit by bit

Address 192.168.45.183 with mask 255.255.255.224 (/27):

183        = 1011 0111
224 (mask) = 1110 0000
AND        = 1010 0000 = 160

Network = 192.168.45.160, block size 32, broadcast 192.168.45.191, hosts .161 – .190.

Choosing a mask from a host count

Hosts neededHost bits h (2^h − 2 ≥ need)PrefixMask
22/30 (or /31 on point-to-point)255.255.255.252
255/27255.255.255.224
1007/25255.255.255.128
3009/23255.255.254.0
100010/22255.255.252.0

Mask mismatch between neighbours — what actually happens

PC A: 10.0.0.10/24, PC B: 10.0.0.200/25, gateway 10.0.0.1.

A sends to BB sends to A
A thinks B is local → ARPs directly → worksB's /25 covers .0 – .127, so .10 is "remote" → sends to the gateway

The result is asymmetric: some traffic goes direct, return traffic via the router; with proxy ARP or ICMP redirects it may even appear to work until a firewall or ACL is added. Always compare the mask on both ends when only some destinations fail.

Invalid masks

A subnet mask must be contiguous ones followed by zeros (RFC 950 allowed non-contiguous masks but they were never practical and are not used today). Values like 255.255.0.255 are rejected for interface addresses, while wildcard masks in ACLs can be non-contiguous — a different concept.

Where to read the mask

SystemCommand
IOSshow ip interface brief (no mask) → show ip interface Gi0/0/1
Windowsipconfig
Linuxip -4 addr show (prefix length)
Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Mask values per octet

Bits in the octetValueBlock size
1128128
219264
322432
424016
52488
62524
72542
82551

A /21 is 255.255.248.0 (8 + 8 + 5 bits). ACLs and OSPF network statements use the wildcard mask, which is the inverse: 255.255.248.0 becomes 0.0.7.255.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docProtocol standard + deployed implementation RFC 791

Authoritative/upstream documentation reviewed for bounded claims in IP Fundamentals → IPv4 → Addressing → Subnet mask. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.rfc-editor.org/rfc/rfc791.html · confidence 94%
Confirmation

Confirm action

Continue?