IPv4 Netmask Calculator
Enter an IPv4 address and CIDR prefix to calculate netmask, network, broadcast, and host range.
Netmask to CIDR Converter
Need the prefix length from a dotted-decimal mask? Convert it instantly below.
What is a netmask?
A netmask is a 32-bit value used in IPv4 networking to separate the network portion of an IP address from the host portion. It tells routers and hosts which part identifies the subnet and which part identifies individual devices.
For example, in 192.168.1.34/24, the /24 means the first 24 bits are the network. The equivalent dotted-decimal netmask is 255.255.255.0.
Why calculating netmask matters
- Subnet planning: You can allocate the right number of addresses per VLAN or segment.
- Routing accuracy: Correct masks avoid traffic leaks and black holes.
- Troubleshooting speed: You quickly identify whether two hosts are in the same subnet.
- Security boundaries: Proper segmentation reduces blast radius during incidents.
How to calculate netmask from CIDR
Step 1: Start with the CIDR prefix
The prefix length (like /26) tells you how many bits are set to 1 in the netmask.
Step 2: Fill bits left to right
A 32-bit mask is divided into four octets. Put 1s for network bits and 0s for host bits.
Step 3: Convert each octet to decimal
Common octet values are:
11111111 = 25511111110 = 25411111100 = 25211111000 = 24811110000 = 24011100000 = 22411000000 = 19210000000 = 128
Example: /27
/27 means 27 ones, then 5 zeros:
11111111.11111111.11111111.11100000 → 255.255.255.224
Manual subnet outcomes you should know
Once you have the mask, you can calculate everything else:
- Network address = IP AND netmask
- Broadcast address = network + host bits all 1
- Usable range = network + 1 through broadcast - 1 (except /31 and /32)
- Wildcard mask = inverse of netmask (used in ACLs)
Common CIDR to netmask reference
| CIDR | Netmask | Usable Hosts |
|---|---|---|
| /8 | 255.0.0.0 | 16,777,214 |
| /16 | 255.255.0.0 | 65,534 |
| /24 | 255.255.255.0 | 254 |
| /25 | 255.255.255.128 | 126 |
| /26 | 255.255.255.192 | 62 |
| /27 | 255.255.255.224 | 30 |
| /28 | 255.255.255.240 | 14 |
| /29 | 255.255.255.248 | 6 |
| /30 | 255.255.255.252 | 2 |
| /31 | 255.255.255.254 | 2 (point-to-point) |
| /32 | 255.255.255.255 | 1 (host route) |
Practical tips to avoid mistakes
- Do not confuse netmask and wildcard mask; they are inverses.
- Ensure masks are contiguous (valid masks have all 1s before any 0s).
- Remember special handling for
/31and/32. - When troubleshooting, compare both IP and mask—not IP alone.
Final thought
Calculating netmask is a foundational networking skill. Once you understand the bit logic, subnetting becomes predictable and much easier. Use the calculator above for speed, then verify with manual reasoning so your design and troubleshooting decisions stay sharp.