Netmask to CIDR
Type a netmask, a prefix length or a wildcard mask to get the other two, plus how many addresses and hosts it covers.
/20
read as a netmaskExample: type your own mask above.
- Netmask in binary
- 11111111.11111111.11110000.00000000
- Netmask in hex
- 0xFFFFF000
- Addresses
- 4,096
- Usable hosts
- 4,094
Common masks
| Prefix | Netmask | Wildcard | Addresses | Usable hosts |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 0.0.7.255 | 2,048 | 2,046 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 |
All 33 are in the subnet cheat sheet.
How it works
A netmask and a prefix length say the same thing two ways: how many leading bits of an address name the network. 255.255.240.0 is 20 one-bits followed by 12 zero-bits, so it's /20. Count the ones in the binary form and you have the prefix.
A wildcard mask is the netmask flipped: 0.0.15.255 for a /20. Cisco access lists (ACLs) and OSPF use it, where a 1-bit means "any value is fine here". To build ACL entries, use the wildcard mask tool.
A netmask must be contiguous: all its ones come first, then all its zeros. Masks like 255.0.255.0 were allowed in very early networks, but no modern system accepts them. Each netmask octet can only be 0, 128, 192, 224, 240, 248, 252, 254 or 255.
To see the network, broadcast and host range for a real address, use the subnet calculator.