Wildcard Masks – Detailed Explanation
1. What is a Wildcard Mask?
Wildcard masks are 32-bit numbers used in Cisco networking to specify which bits in an IP address must match (0) and which bits can vary (1).
Purpose: Create flexible matching rules for ACLs and routing protocol network statements (OSPF, EIGRP).
2. Difference Between Wildcard Mask and Subnet Mask
Feature | Subnet Mask | Wildcard Mask |
---|---|---|
Function | Defines network/host portions | Defines match/don’t-care bits |
Used For | Subnetting, routing | ACLs, OSPF/EIGRP, filtering |
0 Bit Means | Host bits | Must match exactly |
1 Bit Means | Network bits | Ignore (wildcard) |
Calculation | Direct (CIDR) | Inverse of subnet mask |
Key: Subnet Mask – 1 = network, 0 = host.
Wildcard Mask – 0 = match, 1 = wildcard (ignore).
Wildcard Mask – 0 = match, 1 = wildcard (ignore).
3. Wildcard Mask Format
32 bits, 4 octets (like an IP).
0 bit: Must match
1 bit: Ignore (wildcard)
Example:
Wildcard Mask:
Binary:
Interpretation: The last octet is wild (any value matches).
Wildcard Mask:
0.0.0.255
Binary:
00000000.00000000.00000000.11111111
Interpretation: The last octet is wild (any value matches).
4. How Wildcard Masks Work
- If mask bit is 0: The corresponding IP bit must match.
- If mask bit is 1: The corresponding IP bit can be anything.
Example:
IP:
Wildcard:
Matches: All addresses from
IP:
192.168.10.0
Wildcard:
0.0.0.255
Matches: All addresses from
192.168.10.0
to 192.168.10.255
5. Usage in Access Control Lists (ACLs)
Wildcard masks define which hosts/subnets are allowed or denied.
Example: Allow traffic from all of 192.168.1.0/24
:
access-list 10 permit 192.168.1.0 0.0.0.255
Result: Matches any host from
192.168.1.0
to 192.168.1.255
.
6. Examples of Common Wildcard Masks
Description | Example IP | Wildcard Mask | Matches… |
---|---|---|---|
Single Host | 10.1.1.10 | 0.0.0.0 | Only 10.1.1.10 |
/24 Subnet | 192.168.2.0 | 0.0.0.255 | 192.168.2.0 – 192.168.2.255 |
/16 Subnet | 172.16.0.0 | 0.0.255.255 | 172.16.0.0 – 172.16.255.255 |
Any IP | 0.0.0.0 | 255.255.255.255 | All IP addresses |
7. Calculating Wildcard Masks
Formula: Wildcard Mask = 255.255.255.255 – Subnet Mask
- Write the subnet mask.
- Subtract each octet from 255.
- The result is the wildcard mask.
Example Calculation:
Subnet Mask:
Wildcard:
Subnet Mask:
255.255.255.0
Wildcard:
255.255.255.255 – 255.255.255.0 = 0.0.0.255
8. Examples of Wildcard Masks
- Single Host:
access-list 10 permit 192.168.5.10 0.0.0.0
(Matches only 192.168.5.10) - Range of IPs:
To match all even-numbered hosts in the last octet:IP: 192.168.1.0 Wildcard: 0.0.0.254
Matches: 192.168.1.0, 192.168.1.2, 192.168.1.4, etc. - Entire Subnet:
access-list 15 permit 10.1.1.0 0.0.0.255
9. Wildcard Masks vs. Subnet Masks in Routing Protocols
- OSPF Example:
router ospf 1 network 10.10.10.0 0.0.0.255 area 0
Matches all interfaces in 10.10.10.0/24. - EIGRP Example:
router eigrp 100 network 192.168.0.0 0.0.255.255
Includes all interfaces from 192.168.0.0 – 192.168.255.255.
10. Common Mistakes and Troubleshooting
- Remember: 0 = exact match, 1 = wildcard (ignore).
- Incorrect mask causes matches to be too broad/narrow.
- Always recalculate if your subnetting changes.
- Impact: Wrong mask may allow/deny unintended traffic in ACLs or routing.
11. Commands and Verification
- In ACLs:
show access-lists
- In Routing Protocols:
show running-config | include network
- Verify with test traffic and rule counters.
12. Best Practices
- Write wildcard masks clearly, double-check math.
- Avoid ACL overlaps unless intentional.
- Document purpose in config comments.
- Use subnet calculators if unsure.
- Regularly audit your wildcards in ACLs/routing.
Example Scenario:
Allow access only from
Allow access only from
192.168.10.0/24
to a server.
access-list 20 permit 192.168.10.0 0.0.0.255Only hosts with addresses from 192.168.10.0 to 192.168.10.255 are permitted.
Summary Table: Key Points and Exam Tips
Aspect | Wildcard Mask | Subnet Mask |
---|---|---|
0 Bit | Must match exactly | Host bit |
1 Bit | Ignore/wildcard | Network bit |
Use Case | ACLs, OSPF/EIGRP, filtering | Subnetting, routing |
Calculation | 255.255.255.255 – subnet mask | Direct CIDR notation |
Common Error | Reversing 0/1 meaning | Rare, more intuitive |
Exam Tips:
- Wildcard mask = inverse of subnet mask.
- 0 = match, 1 = ignore.
- Used in ACLs, OSPF, EIGRP network statements.
- Always double-check calculations!
- Use
show access-lists
andshow running-config
to verify.