Home/Developer Tools/IPv4 Subnet Calculator

IPv4 Subnet Calculator

Calculate subnet masks, network addresses, usable host ranges, and VLSM tables for IPv4 networks. Enter an IP address and select a subnet mask to get detailed network information.

Subnet Calculator

Traditional Classful Subnets

Class A (/8): 1.0.0.0 to 126.255.255.255
Supports 16,777,214 hosts per network. Used for very large networks.
Class B (/16): 128.0.0.0 to 191.255.255.255
Supports 65,534 hosts per network. Used for medium to large networks.
Class C (/24): 192.0.0.0 to 223.255.255.255
Supports 254 hosts per network. Used for small networks.

Private IPv4 Subnets (RFC 1918)

Class A Private: 10.0.0.0 to 10.255.255.255 (/8)
Reserved for private networks. Not routable on the public internet.
Class B Private: 172.16.0.0 to 172.31.255.255 (/12)
Reserved for private networks. Commonly used in enterprise environments.
Class C Private: 192.168.0.0 to 192.168.255.255 (/16)
Reserved for private networks. Most common for home and small office networks.

Special-Purpose and Functional Subnets

Loopback Subnet: 127.0.0.0/8
Used for loopback addresses (localhost). Traffic never leaves the host.
APIPA Subnet: 169.254.0.0/16
Automatic Private IP Addressing. Used when DHCP fails.
Multicast Subnet: 224.0.0.0 to 239.255.255.255 (Class D)
Reserved for multicast groups. One-to-many communication.
Experimental Subnet: 240.0.0.0 to 255.255.255.255 (Class E)
Reserved for experimental use. Not for general use.

Special CIDR Subnet Sizes

Point-to-Point (/31 or 255.255.255.254):
Defined in RFC 3021 for point-to-point links. Uses both addresses without network/broadcast.
Variable-Length Subnet Masks (VLSM / Custom CIDR):
Allows subnetting with non-standard masks for efficient IP address allocation.

Internet Protocol version 4 (IPv4) is the foundational addressing system of the internet, assigning a unique numerical label to every device connected to a network. As you develop the networking tools for the "Calcthis Page", understanding the mechanics of IPv4 is essential for building an accurate and responsive subnet calculator.

How IPv4 Works

An IPv4 address is a 32-bit number, typically written in "dotted-decimal" format (e.g., 192.168.1.10). This 32-bit structure is divided into four 8-bit sections called octets. Each octet represents a decimal number ranging from 0 to 255.

Every IP address consists of two parts:

  • Network Portion: Identifies the specific network the device belongs to.
  • Host Portion: Identifies the specific device (node) on that network.

The division between these two portions is determined by a Subnet Mask or Classless Inter-Domain Routing (CIDR) notation.

Performing IPv4 Subnet Calculations

Subnetting divides a larger network into smaller, more efficient sub-networks. To build the Subnet/IP calculator for the "Calcthis Page", the logic must accept inputs for an IP and CIDR. It must then calculate and output the Network, Broadcast, and Host Min/Max values.

Here is how those core calculations are performed manually:

  • Understand CIDR Notation: A CIDR suffix like /24 means the first 24 bits of the 32-bit address represent the network. The remaining bits (32 - 24 = 8) represent the host portion.
  • Determine the Subnet Mask: Convert the CIDR bits to binary. A /24 translates to 24 ones followed by 8 zeros: 11111111.11111111.11111111.00000000. In decimal, this translates to 255.255.255.0.
  • Calculate the Network Address: Perform a bitwise AND operation between the IP address and the Subnet Mask to find the network output. For example, using IP 192.168.1.50 and mask 255.255.255.0, the network address is 192.168.1.0.
  • Calculate the Broadcast Address: Take the Network Address and change all host bits to 1 to find the broadcast output. For the 192.168.1.0/24 network, the broadcast address is 192.168.1.255.
  • Determine the Host Range (Min/Max): The usable host range sits strictly between the Network and Broadcast addresses to provide the required Host Min and Host Max outputs.
  • Host Min: Add 1 to the Network Address (e.g., 192.168.1.1).
  • Host Max: Subtract 1 from the Broadcast Address (e.g., 192.168.1.254).
  • Calculate Total Usable Hosts: The formula is 2n - 2, where n is the number of host bits. For a /24 network with 8 host bits, the calculation is 28 - 2 = 254 usable hosts.