What is a wildcard mask?
A wildcard mask is the inverse of a subnet mask. Where a subnet mask uses 1s to mark network bits, a wildcard mask uses 0s to mark the bits that must match and 1s for the bits that are ignored. Network engineers meet wildcard masks mainly in Cisco access lists and in routing protocol network statements.
How to calculate a wildcard mask
Subtract the subnet mask from 255.255.255.255, octet by octet:
Subnet mask 255.255.255.0
Subtract from 255.255.255.255
Wildcard 0.0.0.255Wildcard mask examples
| CIDR | Subnet mask | Wildcard mask | Matches |
|---|---|---|---|
| /32 | 255.255.255.255 | 0.0.0.0 | 1 host |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 addresses |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 addresses |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 addresses |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 addresses |
| /0 | 0.0.0.0 | 255.255.255.255 | any address |
Using wildcard masks in Cisco ACLs
! Permit the 192.168.10.0/24 network
access-list 10 permit 192.168.10.0 0.0.0.255
! Permit a single host
access-list 10 permit host 192.168.10.5 ! same as 192.168.10.5 0.0.0.0
! Advertise a network in OSPF
router ospf 1
network 10.1.0.0 0.0.255.255 area 0The main IP subnet calculator shows the matching Cisco ACL line for any network automatically. For the reverse direction, try the subnet mask calculator.