subnet masks calculator

IPv4 Subnet Masks Calculator

Enter an IPv4 address and either a CIDR prefix or subnet mask to calculate network details instantly.

Tip: You can fill in CIDR, subnet mask, or both (if both are entered they must match).

What Is a Subnet Mask?

A subnet mask is a 32-bit value that splits an IP address into two parts: the network portion and the host portion. In practical terms, it tells your router and devices which part of an address identifies the subnet and which part identifies an individual machine.

For example, in 192.168.1.34/24, the /24 means the first 24 bits are network bits. That corresponds to a subnet mask of 255.255.255.0. Everything in the first three octets belongs to the network, while the last octet is for host addresses.

How to Use This Subnet Masks Calculator

Step-by-step

  • Enter a valid IPv4 address (like 172.16.5.10).
  • Enter either a CIDR prefix (such as 20) or a subnet mask (such as 255.255.240.0).
  • Click Calculate.
  • Review the generated network details: network address, broadcast address, host range, wildcard mask, and host counts.

The calculator automatically handles edge cases like /31 and /32 networks.

What the Calculator Returns

  • Network Address: the first address in the subnet.
  • Broadcast Address: the last address in the subnet (for broadcast-capable networks).
  • First/Last Usable Host: practical host range in most subnets.
  • Total Addresses: all addresses in the block.
  • Usable Hosts: addresses assignable to devices (special handling for /31 and /32).
  • Wildcard Mask: inverse of the subnet mask, often used in ACLs.

CIDR to Subnet Mask Quick Reference

Most common prefixes

  • /8 → 255.0.0.0
  • /16 → 255.255.0.0
  • /24 → 255.255.255.0
  • /25 → 255.255.255.128
  • /26 → 255.255.255.192
  • /27 → 255.255.255.224
  • /28 → 255.255.255.240
  • /29 → 255.255.255.248
  • /30 → 255.255.255.252

Worked Example

Input: 10.20.30.77/26

A /26 mask means blocks of 64 addresses in the last octet. The subnets start at 0, 64, 128, and 192. Since 77 falls into 64–127, the network is 10.20.30.64 and the broadcast is 10.20.30.127.

  • Network: 10.20.30.64
  • Broadcast: 10.20.30.127
  • Usable range: 10.20.30.65 – 10.20.30.126
  • Total addresses: 64
  • Usable hosts: 62

Common Subnetting Mistakes

  • Using non-contiguous masks (for example, 255.0.255.0). Valid masks must have continuous 1-bits followed by 0-bits.
  • Forgetting network and broadcast reservations in typical subnets.
  • Mixing up CIDR and host counts (a higher prefix means fewer hosts).
  • Assuming /31 always has zero usable addresses; modern point-to-point links commonly use both addresses.

Why Subnetting Matters

Good subnet design improves security boundaries, reduces broadcast traffic, and simplifies troubleshooting. Whether you are planning a home lab, enterprise VLAN layout, or cloud VPC segmentation, mastering subnet masks helps you allocate IP space efficiently and avoid painful renumbering later.

🔗 Related Calculators

🔗 Related Calculators