Wildcard masks are essential to learn because they are used as part of command line configuration in ACLs and some routing protocols. They exist because there has to be a way to tell the router which parts of an IP address or network address you want to match.
The matching is done at the binary level, but you can easily configure wildcard masks using the same notation you use for subnet masks. A binary 1 tells the router to ignore the digit and a 0 means match the digit.
The easy way to perform wildcard masking for the CCNA exam is simply to ensure that you add a number to the subnet mask to give you a total of 255. So, if your subnet mask in one octet was 192, you would add 63 to it to make 255. If it was 255, you would add 0. Take a look at the examples below:
| Subnet | 255 | 255 | 255 | 192 |
| Wildcard | 0 | 0 | 0 | 63 |
| Equals | 255 | 255 | 255 | 255 |
| Subnet | 255 | 255 | 224 | 0 |
| Wildcard | 0 | 0 | 31 | 255 |
| Equals | 255 | 255 | 255 | 255 |
| Subnet | 255 | 128 | 0 | 0 |
| Wildcard | 0 | 127 | 255 | 255 |
| Equals | 255 | 255 | 255 | 255 |
You need to enter a wildcard mask if you want your ACL to match a subnet or an entire network. For example, if you wanted to match 172.20.1.0 255.255.224.0, you would enter the following:
Router(config)#access-list 1 permit 172.20.1.0 0.0.31.255
Matching subnet 192.200.1.0 255.255.255.192 would require the following:
Router(config)#access-list 1 permit 192.200.1.0 0.0.0.63
Be careful when applying network statements with OSPF, which also requires a wildcard mask.
The same principle applies when you have a network with two host bits, as you will need to enter an ACL to match these. For example, matching subnet 192.168.1.0 255.255.255.252 or /30, you will need to enter the following:
Router(config)#access-list 1 permit 192.168.1.0 0.0.0.3
I have left off some configuration, as I just want to show the relevant part. This will match hosts 1 and 2 on the 192.168.1.0 network. If you wanted to match hosts 5 and 6 on the 192.168.1.4/30 network, you would enter the following:
Router(config)#access-list 1 permit 192.168.1.4 0.0.0.3
Read through the subnetting and VLSM notes to understand this concept further. It is important!