Concepts / Addressing

Addressing

Wildcard mask

Also called inverse mask, 0.0.0.255, 0.0.0.15, don't-care bits

A mask turned inside out, as Cisco ACLs and OSPF use it: 0 bits must match, 1 bits are free.

A wildcard's 0 bits must match, its 1 bits may be anything
A wildcard's 0 bits must match, its 1 bits may be anything

Read a wildcard mask bit by bit: a 0 bit says the address must match there, a 1 bit lets any value through. 0.0.0.15 frees the last four bits, so 10.0.1.16 0.0.0.15 matches 10.0.1.16 to 10.0.1.31. It is the subnet mask turned over: each byte is 255 minus the mask's, 255 - 240 = 15 for a /28.

10.0.1.16 0.0.0.15 matches 10.0.1.16 to 10.0.1.31: wildcard 15 is 0000 1111, the low four bits free. Each byte is 255 minus the subnet mask's (0.0.0.15 ↔ 255.255.255.240, a /28; 0.0.0.255 ↔ /24), and host and any stand for 0.0.0.0 and 255.255.255.255. Unlike a mask, a wildcard may have gaps (0.0.0.254: the even addresses). Tools that take a mask, like iptables, read a wildcard typed in its place as the opposite.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab