Wildcard Masks Explained: The Backwards Mask in Every ACL
A wildcard mask looks like a subnet mask written backwards — because it is. Where a subnet mask uses 1 bits to mean this part is the network, a wildcard mask uses 0 bits to mean this part must match and 1 bits to mean do not care. That one flip is the whole idea behind every Cisco ACL line and every OSPF network statement, and getting it backwards is one of the most common — and most dangerous — beginner mistakes in networking. This guide converts, decodes, and reads wildcard masks bit by bit, with worked host and range examples you can check yourself.
The short answer
What is a wildcard mask? It is a 32-bit mask used in Cisco access lists (ACLs) and in OSPF network statements that tells the router which bits of an address it must check and which bits it may ignore. A 0 bit means must match. A 1 bit means do not care. So the pair 192.168.1.0 0.0.0.255 means: check the first 24 bits against 192.168.1, and ignore the last 8 bits completely — any final number from 0 to 255 is a match. That is the entire mechanism. Everything else in this guide is learning to read and write those pairs quickly, and to spot the one mistake that turns a careful rule into a wide-open door.
Think of a stencil laid over a row of house numbers. Where the stencil is solid, the number underneath must be exactly the one printed on the stencil. Where the stencil has a hole cut out, anything underneath shows through and is accepted. A subnet mask and a wildcard mask are two stencils that describe the same street in opposite ways: the subnet mask marks the network part, the wildcard mask marks the part you are free to ignore. Once you see it as a stencil, the backwards feeling disappears — the mask is not describing the network, it is describing what the check cares about.
Wildcard mask vs subnet mask: the same street, opposite stencils
| Subnet mask | Wildcard mask | |
|---|---|---|
| Job | Splits an address into network and host parts | Tells a check which bits to compare and which to ignore |
| Meaning of a 1 bit | This bit is network | Do not care about this bit |
| Meaning of a 0 bit | This bit is host | This bit must match |
| For a /24 network | 255.255.255.0 | 0.0.0.255 |
| Where you type it | Interface addresses, routing tables, host settings | Cisco ACLs, OSPF and EIGRP network statements |
| Must the 1 bits be together? | Yes — a normal subnet mask is one unbroken run of 1s, then 0s | In ACLs, no — see the even-hosts example below. In OSPF statements, keep it contiguous in practice |
The conversion is simple arithmetic, octet by octet: wildcard = 255 minus the subnet-mask octet. No binary is needed for the common cases. Work the three you will meet constantly:
| Prefix | Subnet mask | Subtract each octet from 255 | Wildcard mask | Addresses matched |
|---|---|---|---|---|
| /24 | 255.255.255.0 | 0, 0, 0, 255 | 0.0.0.255 | 256 |
| /26 | 255.255.255.192 | 0, 0, 0, 63 | 0.0.0.63 | 64 |
| /30 | 255.255.255.252 | 0, 0, 0, 3 | 0.0.0.3 | 4 |
| /32 (one host) | 255.255.255.255 | 0, 0, 0, 0 | 0.0.0.0 | 1 |
| /0 (everything) | 0.0.0.0 | 255, 255, 255, 255 | 255.255.255.255 | All of IPv4 |
Notice the pattern in the last column: the number of addresses matched is always the wildcard's do-not-care space plus one per ignored bit — in plain terms, for a tidy contiguous mask it is 256 divided by the subnet size, and you can sanity-check any conversion with it. A /26 has 64 addresses, so its wildcard must leave exactly 64 values open: 0.0.0.63 does (0 through 63). If your arithmetic produces a wildcard whose open range does not match the subnet size, the arithmetic is wrong — stop and redo it before the line goes anywhere near a router.
Reading one ACL line bit by bit
Here is the most common ACL line in the world, taken apart slowly:
access-list 10 permit 192.168.1.0 0.0.0.255
Step 1 — split the pair. The first address, 192.168.1.0, is the pattern. The second, 0.0.0.255, is the wildcard that says which parts of the pattern count.
Step 2 — read octet by octet. Octets one to three have wildcard 0, which in binary is 00000000: no bit is ignored, so a packet's first three octets must be exactly 192, 168, and 1. The fourth octet has wildcard 255, binary 11111111: every bit is ignored, so the packet's last octet can be anything at all.
Step 3 — state the match in English. Permit any packet whose source address is in 192.168.1.0 to 192.168.1.255. If you cannot say the English sentence, you do not yet know what the line does — that sentence is the real configuration, and the numbers are just its shorthand.
Host, range, and the clever trick: three more worked examples
Exactly one host. permit host 10.1.1.5 is shorthand for permit 10.1.1.5 0.0.0.0. Wildcard all-zero means every bit must match, so only that one address qualifies. This is the line you use for a single server, a single admin workstation, a single anything.
A small range that is not a whole subnet. permit 10.0.0.8 0.0.0.7 must match the first three octets and the top five bits of the last octet (wildcard 7 is binary 00000111 — only the last three bits are ignored). The last octet can therefore vary only from 8 to 15: eight addresses, the same block a /29 starting at .8 would cover. Ranges that start on a tidy boundary work like small subnets; that tidiness is what makes them readable.
The trick subnet masks cannot do. Because an ACL wildcard does not have to be one unbroken run, permit 192.168.1.0 0.0.0.254 is legal in an ACL. Wildcard 254 is binary 11111110: only the very last bit must match, and the pattern's last bit is 0 — so this matches only the even addresses in the subnet (.0, .2, .4, and so on). It is a genuine technique for matching, say, one of a pair of alternating devices, and also a warning: a wildcard that looks like a typo may be deliberate, and a deliberate-looking one may be a typo. Read the bits before you judge the line. Do not carry this trick into OSPF network statements — there, use the normal contiguous wildcard for the subnet.
Where else you will meet wildcard masks
OSPF network statements. network 192.168.1.0 0.0.0.255 area 0 under OSPF does not advertise that subnet; it selects which interfaces, whose addresses fall inside the must-match pattern, run OSPF in area 0. The mask is read exactly as in an ACL — which is why a host statement, network 10.1.1.5 0.0.0.0 area 0, is a precise and common way to enable OSPF on one interface only.
EIGRP and ACL-based tools. EIGRP network statements use the same convention, and so do the matching fields inside route-maps and prefix filters on Cisco platforms. Learn the stencil once and you can read all of them; the tools in the Try it yourself box below will check your reading for you.
The mistakes that matter
1. Pasting the subnet mask into the ACL. This is the dangerous one. permit 192.168.1.0 255.255.255.0 looks plausible and is catastrophically wrong: wildcard 255 in the first three octets says ignore almost everything, so the line matches addresses across the whole IPv4 space whose last octet happens to fit — not your one subnet. A deny line built the same way can block far more than intended. Convert first, every time, even when you are sure.
2. Forgetting that the pattern address should start on its boundary. permit 192.168.1.7 0.0.0.255 still matches the whole .0 to .255 range, because the last octet is fully ignored — the 7 in the pattern is decoration the router disregards. Harmless here, confusing forever after. Write the first address of the block.
3. Reading the wildcard as a subnet mask out of habit. On a tired night, 0.0.0.3 reads as tiny and harmless. It matches four addresses. 0.0.3.255 reads as a /22-ish mask thing; as a wildcard it matches 1,024 addresses across four third-octet values. Slow down and translate: wildcard first, in English, then judge.
4. Assuming every platform reads it the same way. Wildcard masks in this inverted form are a Cisco IOS convention that many engineers carry in their heads as universal. Other vendors express the same idea differently — Juniper, for example, generally uses ordinary prefix lengths in firewall filters instead of wildcard masks. Check the platform's own syntax before translating a rule set.
Try it yourself
Open the free ACL analyzer and paste in access-list 10 permit 192.168.1.0 0.0.0.255, then add a second line access-list 10 permit 192.168.1.7 0.0.0.255 underneath it and run the analysis: the second line is flagged as covered by the first, because the ignored last octet makes them the same rule — the boundary mistake from this guide, caught by a tool. Then open the free subnet calculator, enter 192.168.1.0/26, and check the two numbers side by side: subnet mask 255.255.255.192 on the calculator, wildcard 0.0.0.63 in your converted ACL line. When those two views agree in your head without effort, wildcard masks have stopped being backwards.
- A wildcard mask is the inverse of a subnet mask: 0 means must match, 1 means do not care. Convert by subtracting each subnet-mask octet from 255 — a /24 mask 255.255.255.0 becomes wildcard 0.0.0.255, a /26 mask 255.255.255.192 becomes 0.0.0.63, and a /30 mask 255.255.255.252 becomes 0.0.0.3.
- The ACL line 192.168.1.0 0.0.0.255 means: the first three octets must match 192.168.1 exactly, and the last octet can be anything — so it matches all 256 addresses from 192.168.1.0 to 192.168.1.255.
- Two special cases cover most real lines: wildcard 0.0.0.0 matches exactly one host (the host keyword), and address 0.0.0.0 with wildcard 255.255.255.255 matches every address (the any keyword).
- Pasting a subnet mask where a wildcard mask belongs is not a harmless typo: permit 192.168.1.0 255.255.255.0 tells the router to ignore almost every bit, so the line matches far more than the one subnet you meant. Always convert, then read the line back bit by bit before you apply it.