Network Bytes · Episode 96 · CCNA 5.6
"Wildcard masks"
Cisco ACLs and OSPF network commands use wildcard masks. A 0 bit means the address bit must match and a 1 bit means anything goes, so a wildcard looks like a subnet mask flipped upside down.
Why ACL masks look backwards
A subnet mask marks the network part of an address with 1 bits: 255.255.255.0. A Cisco ACL rule like
`` access-list 10 permit 10.1.1.0 0.0.0.255 ``
uses a mask that looks like the same thing turned upside down. That is a wildcard mask (Cisco also calls it an inverse mask). It is not describing a subnet; it is telling the router which bits of the address to compare.
The stencil
Picture a stencil laid over the address in binary:
- A 0 bit in the wildcard is a solid cell: the matching address bit must match the rule.
- A 1 bit is a hole: that address bit can be anything.
So 10.1.1.0 with wildcard 0.0.0.255 locks the first three octets (all 0 bits) and leaves the last octet open (all 1 bits). It matches every address from 10.1.1.0 to 10.1.1.255, the whole 10.1.1.x network, and nothing in 10.1.2.x.
The quick trick: subtract from 255
When the mask is a normal, contiguous subnet mask, write 255.255.255.255 on top and the subnet mask underneath, and subtract one octet at a time:
``` 255.255.255.255
- 255.255.255.0 = 0.0.0.255 ```
Two shortcuts you will see in ACLs: host 10.1.1.5 means wildcard 0.0.0.0 (one exact address), and any means 255.255.255.255 (every address).
OSPF uses them too
Under router ospf, the network command also takes a wildcard mask to pick which interfaces join OSPF:
`` router ospf 1 network 10.1.1.0 0.0.0.255 area 0 ``
Any interface whose address falls in 10.1.1.x runs OSPF in area 0.
Try it yourself
Work out the wildcard for a /8 mask (255.0.0.0) with the 255 trick, then check it in Cisco Packet Tracer: create access-list 1 permit 10.0.0.0 <your wildcard> and run show access-lists. Then try access-list 2 permit host 192.168.1.10 and see which wildcard the router shows for host.
Good to know
- CCNA 5.6 covers configuring and verifying access control lists (EP57 covers ACLs; its rule was shown as "/8" for readability, because Cisco ACLs really use wildcard masks).
- In a wildcard mask, a
0bit means the address bit must match and a1bit means "don't care". - For a contiguous mask, the wildcard is the subnet mask subtracted from
255.255.255.255, octet by octet. IOS also accepts non-contiguous wildcards (for example, matching only odd addresses), which the short leaves out. host(wildcard0.0.0.0) andany(255.255.255.255) are shortcuts.- OSPF
networkstatements underrouter ospfalso use wildcard masks (EP46). - "Stencil" is the analogy. The example addresses are private.
For CCNA learners
CCNA exam topic 5.6 covers configuring and verifying ACLs. Be able to read a wildcard mask (0 = match, 1 = ignore) and convert a subnet mask to its wildcard with the 255 trick, for both ACLs and OSPF network commands.
Answer to the comment question
.15. Subtract from 255 octet by octet: 255 − 240 = 15. A 255.255.255.240 mask (a /28) has the wildcard 0.0.0.15, so the wildcard ends in .15.
Test your knowledge
Quick quiz: "Wildcard masks"
4 multiple-choice questions. Pick one answer for each, then check how you did.
Sources
- Cisco, "Configure Commonly Used IP ACLs" (tech note 26448): ACL entries written as an address plus a source or destination wildcard, and the "host" and "any" shortcuts
- Cisco, "Configure and Filter IP Access Lists" (tech note 23602): ACL masks work in reverse from interface masks and are also called inverse or wildcard masks; a 0 bit must match and a 1 bit is ignored
- Cisco, "CCNA 200-301 v1.1 exam topics": 5.6 configure and verify access control lists
Video transcript
Why do router ACLs use masks that look backwards, like 0.0.0.255?
That's a wildcard mask. It tells the router which bits of an address to check, and which to ignore.
Think of a stencil over the address. Zero bits are solid and must match. One bits are holes, and anything goes.
So 10.1.1.0, with wildcard 0.0.0.255, matches the whole 10.1.1 network.
The quick trick: subtract the subnet mask from 255, one octet at a time.
OSPF network commands use wildcards too.
A subnet mask ends in .240. What does the wildcard mask end in? Comment your answer below!
That's your byte.
More from Network Bytes
- EP94"OSPF router ID: how it's chosen"
- EP95"enable secret vs enable password"
- EP97"The native VLAN"
- EP98"OSPF cost"