subbing/24
Subbing › Guides › Wildcard masks explained

Wildcard masks explained

What a wildcard mask is, how it relates to a subnet mask, how to compute one for any network, and how Cisco ACLs use host and any.

A wildcard mask tells an access list which bits of an address matter. A 0 bit must match the configured address; a 1 bit is ignored.

Wildcard = 255.255.255.255 minus the subnet mask

For a /24 the subnet mask is 255.255.255.0, so the wildcard is 0.0.0.255. For a /26 (255.255.255.192) it is 0.0.0.63. For a /20 (255.255.240.0) it is 0.0.15.255. Count the host bits: the wildcard covers 2host bits addresses.

Does an address match a line?

permit 10.1.0.0 0.0.255.255 matches anything whose first two octets are 10.1. Apply the mask the same way you find a network address: 10.1.37.9 AND 255.255.0.0 is 10.1.0.0, which equals the line, so it matches. 10.2.0.1 gives 10.2.0.0: no match.

host and any

host 10.1.1.5 is shorthand for 10.1.1.5 0.0.0.0: every bit must match. any is 0.0.0.0 255.255.255.255: no bit has to match.

Order matters

Lines are checked top-down and the first match wins. A packet that matches no line hits the implicit deny at the end of every ACL. Put specific lines before general ones, and remember that a permit any at the top makes everything below it dead.

Discontiguous wildcards

Wildcards do not have to be contiguous. 0.0.254.255 ignores every bit except the lowest bit of the third octet, which matches only even third octets. The exam rarely asks it, but it explains why the mask is a bit pattern, not a prefix length.

Start drilling acl wildcardsGet the Android app

More on this topic: ACL wildcard mask practice, with sample questions and the full list of question types.