Calculate Wildcard Mask
Intermediate IdentifyQuestion
Given the subnet mask 255.255.255.0, calculate the corresponding wildcard mask and determine the prefix length.
Given
{
"subnet_mask": "255.255.255.0"
}
Answer
{
"wildcard_mask": "0.0.0.255",
"prefix": 24
}
Try to solve it first, then click Reveal Answer
Step-by-Step Explanation
What is a wildcard mask?
A wildcard mask is the bitwise inverse (complement) of a subnet mask. It is used in: - Cisco ACLs (Access Control Lists) - OSPF network statements - Firewall rules
Where a subnet mask has a 1 bit, the wildcard mask has a 0 bit (must match). Where a subnet mask has a 0 bit, the wildcard mask has a 1 bit (don't care / any value allowed).
Step 1: Invert each octet of the subnet mask
The quickest way: subtract each octet from 255.
Subnet mask: 255.255.255. 0
255 255 255 255
− 255 255 255 0
─────────────────
Wildcard: 0. 0. 0.255
Binary verification:
Subnet: 11111111.11111111.11111111.00000000
Invert: 00000000.00000000.00000000.11111111
Wildcard: 0 .0 .0 .255
Step 2: Derive the prefix length
Count the number of consecutive 1 bits in the subnet mask:
255.255.255.0 = 11111111 11111111 11111111 00000000
^─── 8 ───^─── 8 ───^─── 8 ───^─ 0 ─
Total 1 bits = 24
Prefix length = /24
Step 3: Practical usage example
In a Cisco ACL, to permit all hosts in the 192.168.1.0/24 network:
access-list 10 permit 192.168.1.0 0.0.0.255
The wildcard 0.0.0.255 means "match any value in the last octet."
Summary
| Field | Value |
|---|---|
| Subnet mask | 255.255.255.0 |
| Wildcard mask | 0.0.0.255 |
| Prefix length | /24 |