Wildcard Masks – Complete Guide for ACLs & Routing Protocols

1. What Is a Wildcard Mask?

A wildcard mask is a 32-bit number used in Cisco IOS to tell the router which bits of an IP address it must check and which bits it can ignore. The rules are the opposite of a subnet mask:

  • 0 bit — the corresponding IP address bit must match exactly
  • 1 bit — the corresponding IP address bit is ignored (wildcard — any value is acceptable)

Wildcard masks are used in two main places on Cisco devices:

  • Access Control Lists (ACLs) — to define which source or destination addresses a permit or deny rule applies to
  • Routing protocol network statements — in OSPF and EIGRP to tell the router which interfaces to include in the routing process

Related pages: ACL Overview | Applying ACLs | Standard & Extended ACLs | Named ACLs | OSPF Overview | OSPF Single-Area Config | EIGRP Overview | EIGRP Config | Subnetting | Subnet Calculation | IP Addressing | show running-config

2. Wildcard Mask vs. Subnet Mask

Both are 32-bit numbers written in dotted-decimal, but they have opposite bit semantics. This is the single most common source of confusion on the CCNA exam:

Feature Subnet Mask Wildcard Mask
0 bit means Host portion (variable) Must match exactly
1 bit means Network portion (fixed) Ignore — any value OK
Primary function Defines network/host boundary for routing and IP configuration Defines flexible matching rules for ACLs and routing protocol network statements
Used in Interface IP configuration, routing tables, DHCP pools ACL permit/deny rules, OSPF network statements, EIGRP network statements
Notation 255.255.255.0 or /24 (CIDR) 0.0.0.255 (no prefix notation equivalent)
Calculation relationship 255.255.255.255 − subnet mask = wildcard mask

Memory tip: In a subnet mask, 1s mark what you keep (the network). In a wildcard mask, 1s mark what you skip (the “don’t care” bits). They are perfect inverses of each other.

3. How Wildcard Masks Work – Bit-Level Example

The router applies the wildcard mask against each incoming IP address bit by bit. For every bit position where the mask is 0, the IP address bit must equal the reference IP bit. For every bit position where the mask is 1, the IP address bit is not checked.

  Reference IP:   192.168.10. 0
  Wildcard mask:    0.  0. 0.255
  Binary mask:  00000000.00000000.00000000.11111111
                |<——— must match ———>|<— any value —>|

  Result: Matches any IP where the first three octets are 192.168.10
          i.e., 192.168.10.0 through 192.168.10.255 (the entire /24 subnet)
            
  Reference IP:   10.1.1.10
  Wildcard mask:   0.0.0. 0
  Binary mask:  00000000.00000000.00000000.00000000
                |<——————— all bits must match ———————>|

  Result: Matches only 10.1.1.10 (single host match)
            

4. Calculating Wildcard Masks from Subnet Masks

Formula: Wildcard Mask = 255.255.255.255 − Subnet Mask
Subtract each octet of the subnet mask from 255. See Subnet Calculation.

Subnet (CIDR) Subnet Mask Calculation Wildcard Mask
/8 255.0.0.0 255−255 . 255−0 . 255−0 . 255−0 0.255.255.255
/16 255.255.0.0 255−255 . 255−255 . 255−0 . 255−0 0.0.255.255
/24 255.255.255.0 255−255 . 255−255 . 255−255 . 255−0 0.0.0.255
/25 255.255.255.128 255−255 . 255−255 . 255−255 . 255−128 0.0.0.127
/26 255.255.255.192 255−255 . 255−255 . 255−255 . 255−192 0.0.0.63
/27 255.255.255.224 255−255 . 255−255 . 255−255 . 255−224 0.0.0.31
/28 255.255.255.240 255−255 . 255−255 . 255−255 . 255−240 0.0.0.15
/30 255.255.255.252 255−255 . 255−255 . 255−255 . 255−252 0.0.0.3
/32 (host) 255.255.255.255 255−255 . 255−255 . 255−255 . 255−255 0.0.0.0

5. Common Wildcard Mask Reference

Description Reference IP Wildcard Mask Equivalent CIDR Matches…
Single host 10.1.1.10 0.0.0.0 /32 Only 10.1.1.10 — all 32 bits must match; equivalent to keyword host
/30 subnet (WAN link) 10.0.12.0 0.0.0.3 /30 10.0.12.0 – 10.0.12.3 (4 addresses)
/28 subnet 192.168.1.16 0.0.0.15 /28 192.168.1.16 – 192.168.1.31 (16 addresses)
/27 subnet 192.168.1.0 0.0.0.31 /27 192.168.1.0 – 192.168.1.31 (32 addresses)
/26 subnet 192.168.1.0 0.0.0.63 /26 192.168.1.0 – 192.168.1.63 (64 addresses)
/24 subnet 192.168.2.0 0.0.0.255 /24 192.168.2.0 – 192.168.2.255 (256 addresses)
/16 subnet 172.16.0.0 0.0.255.255 /16 172.16.0.0 – 172.16.255.255 (65,536 addresses)
/8 subnet 10.0.0.0 0.255.255.255 /8 10.0.0.0 – 10.255.255.255 (16.7 million addresses)
Any host 0.0.0.0 255.255.255.255 All IP addresses — equivalent to keyword any

Two important IOS shortcuts: host <IP> is equivalent to <IP> 0.0.0.0; any is equivalent to 0.0.0.0 255.255.255.255. Both are accepted interchangeably in ACL and OSPF statements.

6. Non-Contiguous Wildcard Masks

Unlike subnet masks (which must have all 1s on the left and all 0s on the right), wildcard masks can have 1s and 0s in any order. This enables matching patterns that are impossible with a simple subnet:

Use Case Reference IP Wildcard Mask What It Matches
All even hosts in a /24 192.168.1.0 0.0.0.254 192.168.1.0, .2, .4, .6, … .254 (last bit must be 0 = even numbers only)
All odd hosts in a /24 192.168.1.1 0.0.0.254 192.168.1.1, .3, .5, .7, … .255 (last bit must be 1 = odd numbers only)
Summarise two adjacent /24s 192.168.0.0 0.0.1.255 192.168.0.0 – 192.168.1.255 (matches both .0.x and .1.x, because bit 0 of the third octet is wildcarded)
Every other /24 in a range 10.0.0.0 0.0.254.255 10.0.0.x, 10.0.2.x, 10.0.4.x … (even third octet, any fourth octet)

Non-contiguous wildcards are rarely needed in simple network designs but appear on the CCNA exam and in advanced ACL scenarios where you need to match multiple non-adjacent ranges with a single rule.

7. Wildcard Masks in Access Control Lists

ACLs use wildcard masks to define the range of IP addresses a rule matches. The mask follows the source IP in a standard ACL and both source and destination IPs in an extended ACL.

Standard ACL Examples — See Standard & Extended ACLs

! Permit all hosts in 192.168.1.0/24
Router(config)# access-list 10 permit 192.168.1.0 0.0.0.255

! Permit only the single host 192.168.5.10
Router(config)# access-list 10 permit 192.168.5.10 0.0.0.0
! Equivalent using the 'host' keyword:
Router(config)# access-list 10 permit host 192.168.5.10

! Deny all traffic from 172.16.0.0/16
Router(config)# access-list 10 deny 172.16.0.0 0.0.255.255

! Permit all remaining traffic (equivalent to 'permit any')
Router(config)# access-list 10 permit 0.0.0.0 255.255.255.255
Router(config)# access-list 10 permit any    ! same result
            

Extended ACL Example — See Extended ACL guide

! Permit TCP from 192.168.1.0/24 to 10.0.0.0/8 on port 443 (HTTPS)
Router(config)# access-list 100 permit tcp 192.168.1.0 0.0.0.255 10.0.0.0 0.255.255.255 eq 443

! Deny ICMP from any source to a specific host 10.1.1.1
Router(config)# access-list 100 deny icmp any host 10.1.1.1
            

Named ACL Example — See Named ACLs

Router(config)# ip access-list standard PERMIT-MGMT
Router(config-std-nacl)# permit 10.10.10.0 0.0.0.255
Router(config-std-nacl)# deny any
            

8. Wildcard Masks in Routing Protocols

OSPF and EIGRP both use wildcard masks in their network statements to select which locally configured interfaces the routing process will activate on and advertise.

OSPF

! Include all interfaces in the 10.10.10.0/24 range in OSPF area 0
Router(config)# router ospf 1
Router(config-router)# network 10.10.10.0 0.0.0.255 area 0

! Include only the single interface 192.168.1.1 in OSPF area 1
Router(config-router)# network 192.168.1.1 0.0.0.0 area 1

! Include ALL interfaces (use with care in production)
Router(config-router)# network 0.0.0.0 255.255.255.255 area 0
            

See Applying ACLs for interface application (ip access-group). When OSPF evaluates a network statement, it compares each of the router’s interface IP addresses against the reference IP using the wildcard mask. If the bits required to match (mask bits = 0) all agree, that interface is included in OSPF.

EIGRP

! Include all interfaces in 192.168.0.0 – 192.168.255.255 (/16 range)
Router(config)# router eigrp 100
Router(config-router)# network 192.168.0.0 0.0.255.255

! Include only the exact interface 10.1.1.1
Router(config-router)# network 10.1.1.1 0.0.0.0
            

9. Verification Commands

! View all configured ACLs and their match counters
Router# show access-lists

! View a specific ACL
Router# show access-lists 10

! Check which OSPF network statements are configured
Router# show running-config | section router ospf

! Check all network statements across routing protocols
Router# show running-config | include network

! Check which interfaces OSPF is active on (confirms wildcard matching worked)
Router# show ip ospf interface brief

! Verify EIGRP interfaces
Router# show ip eigrp interfaces

! Confirm ACL is applied to the correct interface and direction
Router# show ip interface GigabitEthernet0/0 | include access list
            

10. Common Mistakes and Troubleshooting

Mistake Effect How to Fix
Swapping 0 and 1 bit meaning ACL permits or denies entirely the wrong set of addresses; OSPF/EIGRP activates on wrong interfaces Remember: 0 = must match, 1 = ignore; this is the opposite of a subnet mask
Using a subnet mask instead of wildcard mask e.g., using 255.255.255.0 where 0.0.0.255 is needed — the router may reject the config or match nothing Always subtract the subnet mask from 255.255.255.255 to get the wildcard
Mask too broad in an ACL ACL matches more addresses than intended — could permit traffic from untrusted networks Tighten the wildcard; use show access-lists to check match counters
Mask too narrow in an OSPF network statement Only some interfaces are included; neighbours do not form on excluded interfaces Check show ip ospf interface brief; widen the wildcard or add additional network statements
Not updating wildcard after subnetting changes ACL or routing statement no longer matches the correct new subnet Recalculate the wildcard whenever the subnet mask changes; audit regularly with show access-lists
Using non-contiguous mask unintentionally Matches an unexpected set of addresses if the mask has alternating 0s and 1s Double-check binary; contiguous masks (all 0s followed by all 1s) are usually what is needed for standard subnets

11. Best Practices

  • Always calculate the wildcard by subtracting the subnet mask from 255.255.255.255 — never guess
  • Use the host keyword instead of 0.0.0.0 for single-host matches; use any instead of 0.0.0.0 255.255.255.255 for readability
  • Add remarks to ACLs to document what each wildcard range is intended to match: ip access-list extended FILTER — remark Permit branch VLAN 10 hosts
  • After any subnetting change, review and recalculate all wildcard masks used in ACLs and routing protocol statements
  • Use show access-lists to verify match counters: a counter stuck at zero means the rule is never being matched — likely a wildcard error
  • Avoid overlapping rules in ACLs; overlapping wildcards can cause rules to shadow each other unintentionally
  • Prefer named ACLs over numbered ones; they are easier to document and can be edited in-place without deleting and re-creating the entire list

12. Summary Reference Table

Aspect Wildcard Mask Subnet Mask
0 bit means Must match exactly Host bit (variable)
1 bit means Ignore / wildcard Network bit (fixed)
Used in ACLs, OSPF network, EIGRP network Interface IP config, routing, DHCP pools
Calculation 255.255.255.255 − subnet mask Direct CIDR notation
Single host shortcut host <IP> = <IP> 0.0.0.0 /32
Any host shortcut any = 0.0.0.0 255.255.255.255
Can be non-contiguous? Yes — 1s and 0s can alternate No — must be contiguous 1s then 0s
Common error Reversing 0/1 meaning (treating it like a subnet mask) Rare — CIDR notation is intuitive

13. Key Points & CCNA Exam Tips

  • Wildcard mask: 0 = must match, 1 = ignore — this is the opposite of a subnet mask (where 1 = network, 0 = host)
  • Wildcard mask = 255.255.255.255 − subnet mask (subtract each octet individually)
  • Single-host wildcard = 0.0.0.0 (all bits must match); keyword shortcut: host <IP>
  • Any-host wildcard = 255.255.255.255 (no bits are checked); keyword shortcut: any
  • Common /24 wildcard = 0.0.0.255; /16 wildcard = 0.0.255.255; /8 wildcard = 0.255.255.255
  • Wildcard masks are used in ACL source/destination matching and in OSPF/EIGRP network statements to select which interfaces join the routing process
  • Unlike subnet masks, wildcard masks can be non-contiguous — bits can alternate in any order, enabling matching of patterns like "all even hosts"
  • The most common CCNA exam error is confusing wildcard and subnet masks — always double-check which one the question is asking about
  • Use show access-lists to verify ACL match counters; zero matches usually indicates a wildcard error
  • Use show ip ospf interface brief to confirm OSPF network statements with wildcard masks are activating on the correct interfaces

Wildcard Masks Quiz

1. What is the primary purpose of a wildcard mask in Cisco networking?

Correct answer is B. A wildcard mask is a 32-bit number where each bit position tells the router either to check that bit in the IP address (0 = must match) or to ignore it (1 = ignore). Wildcard masks are used in ACL permit/deny rules and in OSPF/EIGRP network statements to define flexible address-matching ranges.

2. How does a wildcard mask differ from a subnet mask?

Correct answer is D. In a subnet mask: 1 bits identify the network portion and 0 bits identify the host portion. In a wildcard mask the semantics are reversed: 0 bits mean “this bit must match” and 1 bits mean “ignore this bit.” The wildcard mask is calculated as 255.255.255.255 − the subnet mask.

3. What does a wildcard mask of 0.0.0.255 represent?

Correct answer is A. 0.0.0.255 means the first 24 bits (octets 1–3) must match exactly, while the last 8 bits (octet 4) are ignored. Applied to 192.168.2.0, this matches any address from 192.168.2.0 to 192.168.2.255 — the entire /24 subnet. The equivalent subnet mask is 255.255.255.0 (/24).

4. Which wildcard mask matches only a single specific host IP address?

Correct answer is C. A wildcard mask of 0.0.0.0 means every single bit must match — the only address that satisfies this condition is the exact IP specified. This is equivalent to a /32 host route and can also be written using the IOS shortcut keyword host <IP>. Option B (255.255.255.255) is the opposite — it matches any IP address (equivalent to the keyword any).

5. How do you calculate a wildcard mask from a subnet mask?

Correct answer is B. The formula is: Wildcard mask = 255.255.255.255 − subnet mask, applied octet by octet. For example, subnet mask 255.255.255.0: wildcard = (255−255).(255−255).(255−255).(255−0) = 0.0.0.255. For /26 (255.255.255.192): wildcard = (255−255).(255−255).(255−255).(255−192) = 0.0.0.63.

6. Which ACL command permits traffic only from the single host 192.168.5.10?

Correct answer is A. access-list 10 permit 192.168.5.10 0.0.0.0 uses wildcard mask 0.0.0.0, which means all 32 bits must match — only the exact IP 192.168.5.10 is permitted. The equivalent using the IOS shortcut is access-list 10 permit host 192.168.5.10. Option B (0.0.0.255) would permit the entire /24 subnet 192.168.5.0–255.

7. In an OSPF network statement, what does the wildcard mask specify?

Correct answer is D. In router ospf 1 / network 10.10.10.0 0.0.0.255 area 0, the wildcard mask 0.0.0.255 tells OSPF to activate on any interface whose IP address falls within 10.10.10.0–10.10.10.255. OSPF compares each interface IP against the reference address using the wildcard mask; any interface that matches begins sending OSPF hellos and is included in the OSPF process.

8. What is the consequence of confusing the 0 and 1 bit meanings in a wildcard mask?

Correct answer is C. If you treat a wildcard mask like a subnet mask (swapping the meaning of 0 and 1), your ACL rules will match the wrong set of addresses — permitting traffic you meant to deny or denying traffic you meant to permit. In routing protocols, the wrong interfaces will join OSPF or EIGRP. Use show access-lists and show ip ospf interface brief to verify correct behaviour after any wildcard configuration.

9. What does a wildcard mask of 0.0.255.255 match when applied to 172.16.0.0?

Correct answer is B. Wildcard mask 0.0.255.255 means the first two octets (172.16) must match exactly, while the last two octets (16 bits) can be any value from 0 to 255. This matches the entire 172.16.0.0/16 range — 65,536 addresses from 172.16.0.0 to 172.16.255.255. The equivalent subnet mask is 255.255.0.0.

10. Why is it important to document wildcard masks in ACL and routing configurations?

Correct answer is A. Wildcard masks can match non-obvious address ranges, especially non-contiguous ones. Without documentation (ACL remarks, change logs, network diagrams), it becomes very difficult for another engineer to understand what traffic a rule permits or denies weeks or months later. Use remark statements in named ACLs and keep an external record of the subnet each wildcard corresponds to.

Related Topics & Step-by-Step Tutorials

Continue your studies with these closely related pages:

← Back to Home