Subnet / CIDR Calculator

Work out subnet details quickly from IPv4 octets and a CIDR prefix length.

Enter the first IPv4 octet.
Enter the second IPv4 octet.
Enter the third IPv4 octet.
Enter the fourth IPv4 octet.
Enter the subnet prefix, such as 24 for a /24.

Subnet mask

255.255.255.0

Network address192.168.1.0
Broadcast address192.168.1.255
Usable hosts254

How to use this subnet / CIDR calculator

  1. Enter the IP octets

    Type the four octets into IP octet 1, IP octet 2, IP octet 3, and IP octet 4 (e.g. 192, 168, 10, 50).

  2. Set the CIDR prefix length

    Enter the subnet prefix in the CIDR prefix length field (e.g. 24 for a /24, 26 for a /26).

  3. Read the subnet mask

    The calculator returns the subnet mask in dotted-decimal and binary form.

  4. Check network and broadcast

    Review the Network address and Broadcast address results to see the subnet range.

  5. Note usable hosts

    Use the Usable hosts value to plan how many devices can be assigned addresses in the subnet.

Methodology

How this subnet / CIDR calculator works

This subnet calculator derives the subnet mask, network address, broadcast address, and usable-host count from an IPv4 address and a CIDR prefix length. It uses bitwise operations — the same logic that routers and operating-system network stacks perform on every packet — to partition a 32-bit address space into a network portion and a host portion. The prefix length tells the calculator how many of the leading bits identify the network; the remaining bits are available for host addresses. Understanding these boundaries is essential for IP address planning, firewall rule authoring, access-control lists, and troubleshooting routing problems in any TCP/IP network.

Formula
network = IP AND mask • broadcast = IP OR NOT(mask) • traditional usable hosts = 2^(32 − prefix) − 2, with special handling here for /31 and /32
IP The 32-bit IPv4 address entered as four octets (e.g., 192.168.1.100)
mask Subnet mask — a 32-bit value with the first 'prefix' bits set to 1 and the rest set to 0
prefix CIDR prefix length (0–32), indicating how many leading bits define the network
network Network address — the result of bitwise AND between the IP and the mask; identifies the subnet
broadcast Broadcast address — the result of bitwise OR between the IP and the inverted mask; the last address in the subnet
usable hosts Number of assignable host addresses in the subnet, with /31 treated as two point-to-point endpoints and /32 treated as a single host route
Example

Given the IP address 192.168.10.50 with a /26 prefix: the subnet mask is 11111111.11111111.11111111.11000000, which is 255.255.255.192 in dotted-decimal. Bitwise AND of 192.168.10.50 and 255.255.255.192 yields the network address 192.168.10.0. Bitwise OR of 192.168.10.50 and the inverted mask (0.0.0.63) yields the broadcast address 192.168.10.63. The host portion has 32 − 26 = 6 bits, so total addresses = 2^6 = 64, and usable hosts = 64 − 2 = 62.

For 10.0.0.100/22: the subnet mask is 255.255.252.0, network address is 10.0.0.0, broadcast is 10.0.3.255, and usable hosts = 1,022. The /22 leaves 10 host bits (2^10 − 2).

For 172.16.5.1/28: the subnet mask is 255.255.255.240, network address is 172.16.5.0, broadcast is 172.16.5.15, and usable hosts = 14. A /28 is common for small point-of-sale or IoT subnets.

Assumptions
  • The calculator operates on IPv4 only (32-bit addresses). IPv6 subnetting uses a 128-bit address space and different conventions.
  • Prefix lengths of /31 and /32 are valid CIDR notations. This calculator reports /31 as two usable point-to-point endpoints in line with RFC 3021, and /32 as a single host route.
  • Each octet must be in the 0–255 range and the prefix length must be between 0 and 32. Values outside these bounds will produce invalid results.
  • The calculation assumes classless addressing (CIDR). Legacy classful boundaries (Class A/B/C) are not enforced.
Notes
  • For most subnets, the network address (all host bits zero) and broadcast address (all host bits one) cannot be assigned to devices, which is why the traditional formula subtracts two from the total address count.
  • Point-to-point /31 links are a deliberate exception: both addresses are treated as usable endpoints rather than reserving separate network and broadcast slots.
  • When planning VLANs or cloud VPCs, choose a prefix that leaves enough room for future growth — once a subnet is in production, resizing typically means re-addressing the entire range.
  • Supernetting (route aggregation) uses the same bitwise logic in reverse: combine multiple smaller prefixes into a larger one to shrink routing tables.
  • For quick mental math, memorize the /24 = 254 hosts, /25 = 126, /26 = 62, /27 = 30, /28 = 14 progression — each additional prefix bit halves the host count.
Sources
  1. RFC 4632 — Classless Inter-Domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan
  2. RFC 3021 — Using 31-Bit Prefixes on IPv4 Point-to-Point Links
  3. RFC 791 — Internet Protocol (IPv4 address structure and bitwise operations)

Understanding CIDR notation and subnet math

CIDR (Classless Inter-Domain Routing) notation compactly describes how an IPv4 address is split into a network portion and a host portion. The prefix length (e.g. /24) tells you how many of the 32 bits identify the network; the remaining bits define host addresses within that subnet. A /24 leaves 8 host bits, so 2^8 = 256 total addresses, with 254 typically usable after reserving the network and broadcast addresses. Subnet math relies on bitwise operations: the network address is the IP AND the subnet mask, and the broadcast address is the IP OR the inverted mask. Routers and firewalls use this logic on every packet to decide whether an address belongs to a local subnet or must be forwarded elsewhere.

Practical developer use cases for subnetting

Developers encounter subnet calculations when designing cloud VPCs, writing firewall rules, debugging routing issues, and configuring access-control lists. In AWS, GCP, or Azure, you choose CIDR blocks for VPCs and subnets; understanding prefix lengths helps you size subnets correctly and avoid overlap. Security engineers use CIDR ranges in iptables, nftables, and cloud security groups to allow or deny traffic by IP range. When troubleshooting connectivity, knowing the network and broadcast addresses helps you verify whether a host is inside the expected range. DevOps teams also use subnet math when planning IP allocation for Kubernetes clusters, container networks, and multi-tenant architectures.

Subnet / CIDR calculator FAQs

What is the difference between a subnet mask and a CIDR prefix?

They express the same information in different notation. A /24 prefix means 24 leading one-bits, which corresponds to the dotted-decimal subnet mask 255.255.255.0. CIDR notation is more compact and is the standard used in modern routing configuration.

Why are two addresses subtracted from the total to get usable hosts?

In traditional IPv4 subnetting, the first address in a subnet (all host bits zero) is reserved as the network address and the last address (all host bits one) is reserved as the broadcast address. Neither can be assigned to a device, so usable hosts = 2^(host bits) − 2. A /31 point-to-point link is the notable exception.

Can I use this calculator for private IP ranges?

Yes. The bitwise math is identical for private (RFC 1918) and public addresses. Common private ranges are 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16.

What does a /32 prefix mean?

A /32 prefix identifies a single host address with no host bits. It is commonly used in routing tables and firewall rules to match exactly one IP address, and this calculator reports that as one usable host route.

Does this work for IPv6?

No. This calculator is designed for IPv4's 32-bit address space. IPv6 uses 128-bit addresses, a different prefix-length range (typically /48 to /128), and does not reserve a broadcast address in the same way.

Written by Jan Křenek Founder and lead developer
Reviewed by DigitSum Methodology Review Formula verification and QA
Last updated Mar 10, 2026

Use this as an estimate and validate important decisions with a qualified professional.

Inputs stay in the browser unless a future feature explicitly tells you otherwise.