Use it to convert between prefix length and dotted mask, and to spot a host or interface with the wrong mask.
Subnet mask
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.
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.
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
- Using a subnet mask in an ACL or OSPF
networkstatement 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.
Operational reference
Fast context before you go deeper.
show ip interface Gi0/0 | include Internet addressVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
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 · 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.
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
| Prefix | Mask | Wildcard | Hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 0.0.0.255 | 254 |
| /25 | 255.255.255.128 | 0.0.0.127 | 126 |
| /27 | 255.255.255.224 | 0.0.0.31 | 30 |
| /29 | 255.255.255.248 | 0.0.0.7 | 6 |
| /30 | 255.255.255.252 | 0.0.0.3 | 2 |
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 needed | Host bits h (2^h − 2 ≥ need) | Prefix | Mask |
|---|---|---|---|
| 2 | 2 | /30 (or /31 on point-to-point) | 255.255.255.252 |
| 25 | 5 | /27 | 255.255.255.224 |
| 100 | 7 | /25 | 255.255.255.128 |
| 300 | 9 | /23 | 255.255.254.0 |
| 1000 | 10 | /22 | 255.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 B | B sends to A |
|---|---|
| A thinks B is local → ARPs directly → works | B'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
| System | Command |
|---|---|
| IOS | show ip interface brief (no mask) → show ip interface Gi0/0/1 |
| Windows | ipconfig |
| Linux | ip -4 addr show (prefix length) |
Mask values per octet
| Bits in the octet | Value | Block size |
|---|---|---|
| 1 | 128 | 128 |
| 2 | 192 | 64 |
| 3 | 224 | 32 |
| 4 | 240 | 16 |
| 5 | 248 | 8 |
| 6 | 252 | 4 |
| 7 | 254 | 2 |
| 8 | 255 | 1 |
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.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
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%