calculating netmask

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 = 255
  • 11111110 = 254
  • 11111100 = 252
  • 11111000 = 248
  • 11110000 = 240
  • 11100000 = 224
  • 11000000 = 192
  • 10000000 = 128

Example: /27

/27 means 27 ones, then 5 zeros:

11111111.11111111.11111111.11100000255.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
/8255.0.0.016,777,214
/16255.255.0.065,534
/24255.255.255.0254
/25255.255.255.128126
/26255.255.255.19262
/27255.255.255.22430
/28255.255.255.24014
/29255.255.255.2486
/30255.255.255.2522
/31255.255.255.2542 (point-to-point)
/32255.255.255.2551 (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 /31 and /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.

🔗 Related Calculators