subnet.im

Wildcard Mask Cheat Sheet

The wildcard mask — also called the inverse mask — for every IPv4 prefix from /0 to /32, alongside the subnet mask it inverts. Cisco access lists, OSPF and EIGRP all expect this form rather than the subnet mask.

Wildcard MaskCIDRSubnet MaskAddresses MatchedHost Bits
0.0.0.0/32255.255.255.25510
0.0.0.1/31255.255.255.25421
0.0.0.3/30255.255.255.25242
0.0.0.7/29255.255.255.24883
0.0.0.15/28255.255.255.240164
0.0.0.31/27255.255.255.224325
0.0.0.63/26255.255.255.192646
0.0.0.127/25255.255.255.1281287
0.0.0.255/24255.255.255.02568
0.0.1.255/23255.255.254.05129
0.0.3.255/22255.255.252.01,02410
0.0.7.255/21255.255.248.02,04811
0.0.15.255/20255.255.240.04,09612
0.0.31.255/19255.255.224.08,19213
0.0.63.255/18255.255.192.016,38414
0.0.127.255/17255.255.128.032,76815
0.0.255.255/16255.255.0.065,53616
0.1.255.255/15255.254.0.0131,07217
0.3.255.255/14255.252.0.0262,14418
0.7.255.255/13255.248.0.0524,28819
0.15.255.255/12255.240.0.01,048,57620
0.31.255.255/11255.224.0.02,097,15221
0.63.255.255/10255.192.0.04,194,30422
0.127.255.255/9255.128.0.08,388,60823
0.255.255.255/8255.0.0.016,777,21624
1.255.255.255/7254.0.0.033,554,43225
3.255.255.255/6252.0.0.067,108,86426
7.255.255.255/5248.0.0.0134,217,72827
15.255.255.255/4240.0.0.0268,435,45628
31.255.255.255/3224.0.0.0536,870,91229
63.255.255.255/2192.0.0.01,073,741,82430
127.255.255.255/1128.0.0.02,147,483,64831
255.255.255.255/00.0.0.04,294,967,29632

A 0 bit in a wildcard mask must match; a 1 bit is ignored. Addresses matched counts every address in the block, including the network and broadcast addresses.

Reading a Wildcard Mask

A subnet mask and a wildcard mask carry the same boundary in opposite polarity. For a /26 network the subnet mask is 255.255.255.192 — the first 26 bits are 1 and must match. The wildcard mask is 0.0.0.63: the same 26 bits are 0, and the final six are 1, free to take any value.

The arithmetic is a per-octet subtraction from 255, so the two masks in each row of the table above always sum to 255.255.255.255.

Common Wildcard Masks

  • 0.0.0.0 /32. Matches one address exactly. Cisco ACLs accept the keyword host as shorthand.
  • 0.0.0.255 /24. Matches a whole /24 — the last octet is free to vary.
  • 0.0.0.63 /26. Matches a /26, the usual size for a small VLAN.
  • 0.0.255.255 /16. Matches a /16, common in OSPF area statements.
  • 255.255.255.255 /0. Matches every address. Written as the keyword any in an ACL.

Frequently Asked Questions

What is a wildcard mask?

A wildcard mask is the bitwise inverse of a subnet mask: every 1 becomes a 0 and every 0 becomes a 1. Where a subnet mask marks which bits must match to be in the network, a wildcard mask marks which bits are free to vary. A 0 in a wildcard mask means the corresponding address bit must match exactly; a 1 means it is ignored.

How do you convert a subnet mask to a wildcard mask?

Subtract each octet of the subnet mask from 255. A /24 subnet mask of 255.255.255.0 becomes the wildcard mask 0.0.0.255, and a /26 mask of 255.255.255.192 becomes 0.0.0.63. The table above lists the result for all 33 prefix lengths.

Where are wildcard masks used?

Cisco IOS access control lists, OSPF network statements and EIGRP network statements all take a wildcard mask rather than a subnet mask. For example, 'network 10.1.0.0 0.0.255.255 area 0' matches the whole of 10.1.0.0/16 because the wildcard leaves the final two octets free to vary.

Is a wildcard mask the same as an inverse mask?

Yes. 'Inverse mask' and 'wildcard mask' describe the same value, and Cisco documentation uses both. Unlike a subnet mask, a wildcard mask does not have to be contiguous — a discontiguous wildcard can match, for instance, only odd-numbered subnets — though contiguous wildcards mirroring a real subnet mask are what almost all configurations use.