What is Netmask to CIDR Conversion?
Netmask to CIDR conversion transforms subnet masks between two equivalent notations. The dotted-decimal format (like 255.255.255.0) expresses the mask as four octets, while CIDR notation (like /24) simply counts the number of network bits. Both represent the same information – the division between network and host portions of an IP address.
Different network devices and documentation use different formats. Windows typically displays subnet masks in dotted-decimal, while Linux often uses CIDR notation. Cloud platforms like AWS exclusively use CIDR. Being able to convert between formats is essential for network administrators working across different systems. For complete subnet calculations, use our subnet calculator.
Quick Conversion Tip
The CIDR number equals the count of 1 bits in the binary representation. 255.255.255.0 = 11111111.11111111.11111111.00000000 = 24 ones = /24. Memorize common conversions: /8 = 255.0.0.0, /16 = 255.255.0.0, /24 = 255.255.255.0.
How the Conversion Works
Netmask to CIDR
To convert a subnet mask to CIDR, convert each octet to binary and count the total 1 bits. For 255.255.255.192: 255 = 8 ones, 255 = 8 ones, 255 = 8 ones, 192 = 2 ones. Total: 8+8+8+2 = 26, so the CIDR is /26.
CIDR to Netmask
To convert CIDR to netmask, create a 32-bit binary number with that many leading 1s, then convert each 8-bit group to decimal. For /26: 26 ones followed by 6 zeros = 11111111.11111111.11111111.11000000 = 255.255.255.192.
Common Conversions Reference
| CIDR | Netmask | Addresses | Common Use |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | Class A default |
| /16 | 255.255.0.0 | 65,536 | Class B default |
| /24 | 255.255.255.0 | 256 | Class C / Standard LAN |
| /25 | 255.255.255.128 | 128 | Half /24 |
| /26 | 255.255.255.192 | 64 | Quarter /24 |
| /27 | 255.255.255.224 | 32 | Small subnet |
| /28 | 255.255.255.240 | 16 | Very small subnet |
| /30 | 255.255.255.252 | 4 | Point-to-point link |
| /32 | 255.255.255.255 | 1 | Single host |
Valid Subnet Mask Values
Not all combinations of numbers make valid subnet masks. Each octet can only contain specific values that represent consecutive 1 bits:
- 0 = 00000000 (0 bits)
- 128 = 10000000 (1 bit)
- 192 = 11000000 (2 bits)
- 224 = 11100000 (3 bits)
- 240 = 11110000 (4 bits)
- 248 = 11111000 (5 bits)
- 252 = 11111100 (6 bits)
- 254 = 11111110 (7 bits)
- 255 = 11111111 (8 bits)
Additionally, once an octet is less than 255, all following octets must be 0. For example, 255.255.240.0 is valid, but 255.240.255.0 is not. The converter validates your input and reports invalid masks. For more details on subnet masks, see our subnet mask calculator.
Wildcard Mask
The wildcard mask is the bitwise inverse of the subnet mask. It's used in Cisco ACLs and OSPF configuration. This converter also shows the wildcard mask for convenience. For example, netmask 255.255.255.0 has wildcard 0.0.0.255. Our wildcard mask calculator provides additional wildcard functionality.
Where Each Format is Used
Dotted-Decimal (Netmask)
- Windows network configuration
- Many router interface configurations
- DHCP server settings
- Legacy documentation
CIDR Notation
- Linux network configuration
- AWS, Azure, GCP cloud platforms
- Routing table displays
- Modern documentation and diagrams
- Firewall rules
For detailed CIDR block analysis, use our CIDR calculator. To see all IP addresses in a range, try our CIDR to IP range calculator.