From netmask to prefix
Convert 255.255.254.0 to CIDR
Select Subnet mask as the input format and enter 255.255.254.0. The result is /23, with wildcard mask 0.0.1.255, 512 total addresses, and normally 510 usable hosts.
The slash number counts network bits, not addresses, as described in RFC 4632. To apply a prefix to an actual address, use the CIDR to IP range calculator.
Quick example
Convert /24 to 255.255.255.0
A /24 prefix reserves 24 bits for the network and leaves 8 bits for addresses. Its subnet mask is 255.255.255.0, its wildcard mask is 0.0.0.255, and it contains 256 total addresses with 254 normally usable by hosts.
Common conversions
CIDR, subnet mask, and wildcard mask table
Use this table as a quick reference for frequently used IPv4 prefixes. Address counts include the entire block.
| CIDR | Subnet mask | Wildcard mask | Addresses |
|---|---|---|---|
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 |
| /21 | 255.255.248.0 | 0.0.7.255 | 2,048 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 |
Reading masks
How the three formats relate
CIDR prefix
The number after the slash is the count of network bits. A larger prefix leaves fewer host bits and creates a smaller address block.
Subnet mask
Also called a netmask. Network bits appear as consecutive ones and host bits as consecutive zeroes. In dotted decimal, each group of eight bits becomes one octet.
Wildcard mask
A wildcard mask is the inverse of the subnet mask: every one becomes zero and every zero becomes one. Network access-control rules commonly use it.
Address count
Raise 2 to the number of host bits. Traditional subnets reserve the network and broadcast addresses, while /31 and /32 have special uses.
Validation
Subnet mask bits must be contiguous
A valid CIDR mask has one uninterrupted run of 1 network bits followed by 0 host bits. For example, 255.255.255.0 is valid, but 255.0.255.0 is not. This converter rejects masks that cannot be represented by a single CIDR prefix.
Some ACL systems permit noncontiguous wildcard masks, as Cisco's access-list documentation explains. Those are outside this single-prefix converter's scope; rejection here does not mean every ACL wildcard must be contiguous.
For usable address ranges, use the IPv4 subnet calculator. Its host counts include the special /31 point-to-point and /32 host-route cases; a provider may reserve additional addresses.
Common questions
Subnet mask and CIDR conversion FAQ
Is a netmask the same as a subnet mask?
For an IPv4 network, netmask and subnet mask refer to the same mask. Both distinguish the network bits from the host bits. A wildcard mask uses the opposite bit values.
How do I convert a subnet mask to CIDR notation?
Write the mask in binary and count its contiguous one bits. For example, 255.255.254.0 has 8 + 8 + 7 = 23 network bits, so its prefix is /23.
How do I calculate a wildcard mask?
Subtract each subnet-mask octet from 255. For 255.255.254.0, the wildcard is 0.0.1.255. This converter supports wildcard masks that describe one CIDR block.
Why does this converter reject a noncontiguous wildcard?
Some access-control lists support noncontiguous wildcard masks, but those masks do not describe one CIDR block. This converter only accepts wildcards whose inverse is a contiguous subnet mask.
Can a subnet mask tell me my IP range?
Not by itself. The mask gives the network size, but you also need an IP address in that network to find its first and last addresses.