Wildcard mask calculator
Convert a prefix or subnet mask to the wildcard mask used in ACLs and OSPF.
Runs on your device · nothing is uploaded
What is a wildcard mask?
A wildcard mask is the opposite of a subnet mask: every 0 bit means "must match" and every 1 bit means "any value". Cisco access lists and OSPF network statements use them. The quick way to work one out is to subtract each octet of the subnet mask from 255.
| Prefix | Subnet mask | Wildcard |
|---|---|---|
| /24 | 255.255.255.0 | 0.0.0.255 |
| /27 | 255.255.255.224 | 0.0.0.31 |
| /30 | 255.255.255.252 | 0.0.0.3 |
Where wildcard masks are used
- Access lists:
access-list 10 permit 192.168.10.0 0.0.0.255matches every address from 192.168.10.0 to 192.168.10.255. - OSPF:
network 10.1.1.0 0.0.0.255 area 0enables OSPF on interfaces in that range. - Shortcuts:
0.0.0.0matches one exact address (thehostkeyword), and255.255.255.255matches anything (theanykeyword).
A worked example
For 192.168.20.64/26, the subnet mask is 255.255.255.192. Subtract each octet from 255: 255−255, 255−255, 255−255, 255−192. The wildcard mask is 0.0.0.63, so the ACL line is permit 192.168.20.64 0.0.0.63, matching .64 to .127.
Beyond subnet masks
Wildcards don't have to be a neat block of 1s. 10.0.0.0 0.0.254.255 matches every 10.0.x.y address where x is even, because the last bit of the third octet must be 0. It is clever, but hard to read; most teams avoid it in production.
Common mistakes
- Typing the subnet mask (
255.255.255.0) where IOS expects a wildcard. In an ACL that matches almost nothing you intended. - Forgetting the implicit "deny any" at the end of every ACL.
- Putting a broad permit above a specific deny. ACLs are read top to bottom and stop at the first match.
Practise with our ACLs and wildcard masks note and the ACL builder tool.