Wildcard Mask Calculator

Convert between subnet masks, prefix lengths and wildcard masks for ACLs and routing filters.

  • Runs locally in your browser
  • No upload required

Try it

Prefix length
/24
Subnet mask
255.255.255.0
Wildcard mask
0.0.0.255
Total addresses
256
Usable hosts
254
ACL example
permit ip 10.0.0.0 0.0.0.255 any
Prefix: /24
Netmask: 255.255.255.0
Wildcard: 0.0.0.255

Supported formats

Input
text
Output
text, number

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

Prefix /24: netmask 255.255.255.0, wildcard 0.0.0.255.

How it works

  • Resolved the input to a prefix length.
  • Built the netmask from the prefix as an unsigned 32-bit integer.
  • Inverted every bit to produce the wildcard mask.
textSelect to copy
wildcard = NOT netmask
  • A wildcard mask is the bitwise complement of the subnet mask.
  • Only contiguous netmasks have a defined prefix length and are accepted.

Methodology

  1. Parse the input as a netmask/prefix or as a wildcard mask.
  2. Invert a wildcard to recover the netmask and confirm the netmask is contiguous.
  3. Derive the prefix length, netmask, wildcard and host counts from the resolved boundary.

Usage

  1. Choose whether the input is a netmask/prefix or a wildcard mask.
  2. Enter the value.
  3. Read the prefix, netmask and wildcard.

Examples

These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.

A /24 netmask to wildcard

jsonSelect to copy
{
  "kind": "netmask",
  "mask": "255.255.255.0"
}

A wildcard back to a prefix

jsonSelect to copy
{
  "kind": "wildcard",
  "mask": "0.0.0.255"
}

A /30 from prefix notation

jsonSelect to copy
{
  "kind": "netmask",
  "mask": "/30"
}

Limitations

Why routers use inverse masks

Access control lists express a match as a base address plus a wildcard mask: a 1 in the wildcard means the corresponding address bit is ignored, and a 0 means it must match. That is exactly the complement of the subnet mask.

Because wildcards are just bit patterns, they can be non-contiguous, but a non-contiguous wildcard no longer corresponds to a single subnet and has no prefix length. This tool states that boundary instead of inventing a prefix.

Frequently asked questions

What is a wildcard mask?
It is the bitwise inverse of a subnet mask: where the netmask has a 1 the wildcard has a 0, and vice versa.
Can a wildcard mask be non-contiguous?
Wildcards can be non-contiguous, but then their inverse is not a valid subnet mask and has no prefix length, so this tool rejects it.

Sources

  1. RFC 1812: Requirements for IP Version 4 Routers — IETF