IPv4 Subnet Calculator

Calculate subnet masks, host ranges, and broadcast addresses for IPv4.

IPv4 Subnet Calculator

IP: 192.168.1.10

Prefix: /24

Subnet Mask: 255.255.255.0

Wildcard Mask: 0.0.0.255

Network: 192.168.1.0

Broadcast: 192.168.1.255

Host Range: 192.168.1.1 - 192.168.1.254

Usable Hosts: 254

What This Tool Does

  • IP routing and network segmentation are the core building blocks of internet systems, cloud VPC structures (such as AWS VPCs, Azure VNets, and Google Cloud VPCs), and local network engineering. An IPv4 address is a 32-bit unsigned integer divided into two components: the network address (which identifies the network segment) and the host address (which identifies a specific network interface on that segment). Subnetting is the architectural practice of partitioning a single physical or virtual network into smaller, logically isolated sub-networks.
  • Historically, the internet was divided into rigid, byte-aligned classes (Class A, B, and C). In 1993, RFC 1519 introduced Classless Inter-Domain Routing (CIDR) to replace classful addressing with a flexible subnetting scheme. CIDR uses slash notation (e.g., /24) to specify the exact number of bits allocated to the network prefix, leaving the remaining bits to define the host space. Computing subnet masks, address ranges, and broadcast boundaries requires executing bitwise math (bitwise AND, OR, and NOT operations) on binary representations of IP addresses. Calculating these parameters correctly prevents overlapping IP blocks, routing conflicts, and gateway communication issues.
  • The IPv4 Subnet Calculator on ScriptPulse.tools automates this binary math, allowing developers and network engineers to input an IP address and prefix length to calculate essential network parameters in real time. The utility calculates the subnet mask, network address, broadcast address, first usable host, last usable host, and total usable host count. All calculations are executed locally in the browser, providing a secure and fast tool for building VPC infrastructure templates, firewall rules, and container network configurations without sending data to a server.

How It Works

  • The calculator parses the input IPv4 address string (split into 4 octets) and the CIDR prefix (ranging from /0 to /32).
  • It converts the IP address into a 32-bit unsigned integer. The subnet mask is computed by setting the first prefix bits to 1 and the remaining bits to 0.
  • The network address is calculated by performing a bitwise AND operation between the IP address integer and the subnet mask integer.
  • The broadcast address is calculated by performing a bitwise OR between the IP address and the bitwise NOT of the subnet mask. Usable host ranges are then determined by adding 1 to the network address and subtracting 1 from the broadcast address, converting all 32-bit integers back to dotted-decimal strings.

Usage

  1. Enter your base IPv4 address (e.g., 192.168.1.1) in the address input field.
  2. Select or type the target CIDR prefix length (e.g., 24) to determine the subnet size.
  3. Review the calculated subnet parameters, usable host range, and address limits shown in the results panel.
  4. Copy specific network properties (like the broadcast address or usable range) using the copy buttons.
  5. Integrate the calculated CIDR block details into your Terraform configurations, router settings, or firewall rules.

Examples

  • Home Router Network — Inputting `192.168.1.1/24` outputs a mask of `255.255.255.0` with 254 usable host IPs (range `.1` to `.254`).
  • Small Cloud VPC Subnet — Inputting `10.0.0.0/27` outputs a mask of `255.255.255.224` supporting 30 usable hosts (range `.1` to `.30`).
  • Wide Enterprise Segment — Inputting `172.16.0.0/16` outputs a mask of `255.255.0.0` supporting 65,534 usable hosts.
  • Point-to-Point Tunnel — Inputting `10.0.0.4/31` outputs a mask of `255.255.255.254` with 2 usable hosts matching RFC 3021 standards.
  • Loopback / Single Host — Inputting `127.0.0.1/32` outputs a mask of `255.255.255.255` representing a single unique device interface.

Real-World Use Cases

  • Planning CIDR block allocations for virtual private clouds (VPCs) and routing subnets in AWS, GCP, or Azure.
  • Configuring Kubernetes pod CIDR allocations and service IP pools to prevent route conflicts inside container orchestration clusters.
  • Determining subnet boundaries and default gateway IPs for local corporate office networking or VPN tunneling structures.
  • Troubleshooting local connectivity issues by validating whether two host IPs reside within the same broadcast domain.
  • Designing virtualized home labs and sandbox environments with optimal host counts per segment.

Best Practices

  • Design cloud network architectures with spare subnet capacity to accommodate future service expansions and multi-region routing groups.
  • Always document allocations in a shared IP Address Management (IPAM) sheet or version-controlled infrastructure-as-code files.
  • Use CIDR notation exclusively for modern infrastructure; classful networking terms (Class A, Class B, etc.) are obsolete.
  • Configure firewalls to align precisely with subnet boundaries to prevent security leaks between segmented zones.
  • Use small subnet allocations (such as /28 or /29) for database-only clusters to minimize the broadcast domain size.

Common Mistakes

  • Forgetting that the network address (all host bits 0) and the broadcast address (all host bits 1) are reserved, meaning standard usable host counts are always 2^(32-prefix) - 2.
  • Overlapping CIDR blocks within the same routing table or VPC (e.g., launching subnets `10.0.0.0/24` and `10.0.0.128/25` together), leading to routing loops or packet loss.
  • Assuming /31 subnets have no usable hosts: while standard formulas suggest zero hosts (2-2=0), RFC 3021 explicitly allows using both addresses for point-to-point connections.
  • Leaking private IP spaces (RFC 1918 blocks like 10.0.0.0/8) to public web routers, causing packet drops or security issues.
  • Off-by-one errors when partitioning consecutive subnets, such as placing the start address of a new subnet at the broadcast address of the preceding subnet.

Limitations

  • Results should be validated in your target runtime before production use.
  • Extremely large input payloads may be constrained by browser memory and performance limits.

Technical Reference Guide

  • CIDR Notation: Standardized by RFC 1519, representing an IP address and network prefix length (e.g., 10.0.0.0/8).
  • Subnet Mask: A 32-bit mask where network bits are 1s and host bits are 0s. Used by routers to extract the network ID via bitwise AND.
  • Network Address: The first address of a subnet block, representing the segment identity. Host bits are all zeros.
  • Broadcast Address: The last address of a subnet block, used to send packets to all hosts on the segment. Host bits are all ones.
  • Private Ranges (RFC 1918): IP ranges reserved for local networks: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16.
  • Point-to-Point Links (RFC 3021): Standard allowing /31 subnets (with only 2 addresses) to be fully utilized on point-to-point tunnels.
  • Loopback / Host (RFC 3330): Standard defining /32 blocks as representing a single interface (no routing network).

FAQ

  • Why are two IP addresses subtracted from every subnet?

    In standard classless routing, two IP addresses are reserved in each subnet: the first address (network address, where all host bits are 0) represents the network segment identity, and the last address (broadcast address, where all host bits are 1) is used for broadcast messaging. This makes the number of usable host addresses 2^(32-prefix) - 2.

  • What private IP address ranges are reserved under RFC 1918?

    RFC 1918 reserves three private address blocks for local networks: 10.0.0.0 to 10.255.255.255 (10.0.0.0/8), 172.16.0.0 to 172.31.255.255 (172.16.0.0/12), and 192.168.0.0 to 192.168.255.255 (192.168.0.0/16). These ranges cannot be routed on the public internet.

  • How does a subnet mask work?

    A subnet mask is a 32-bit filter of 1s and 0s. When a device sends a packet, it applies a bitwise AND between the target IP and the subnet mask. If the result matches its own network ID, the packet is sent directly to the local subnet interface; if not, it is routed to the default gateway.

  • Can I use a /31 subnet for networks?

    Yes, but only for point-to-point links. RFC 3021 allows using /31 subnets (which contain exactly 2 IP addresses) for point-to-point connections. Since there are only two endpoints on the link, neither broadcast nor network identifiers are needed, making both IPs usable.

  • What is classless inter-domain routing (CIDR)?

    CIDR (introduced in RFC 1519) replaced classful networks (A, B, C) with variable-length prefix routing. It allows networks to be split at arbitrary bit boundaries rather than full octets, dramatically reducing IP address waste across the internet.

  • What does a /32 subnet represent?

    A /32 subnet mask (255.255.255.255) leaves zero bits for hosts. It represents a single, specific IP address. It is typically used for loopback interfaces, VPN endpoint targets, or single-host firewall whitelist rules.

  • How many usable IP addresses are in a /24 subnet?

    A /24 subnet allocates 24 bits for the network and leaves 8 bits for hosts. The total number of IPs is 2^8 = 256. After subtracting the reserved network and broadcast addresses, there are 256 - 2 = 254 usable host addresses.

  • Can two subnets overlap in a cloud VPC configuration?

    No. Cloud routers and security groups cannot resolve routes for overlapping IP CIDR ranges within the same VPC. Attempting to deploy overlapping subnets will trigger validation errors or route collision issues.

Related Tools

Explore related utilities inside the Infrastructure Hub workshop for complementary engineering workflows.

View all Infrastructure Hub tools