Ip Range Calculator Subnet Mask

IP Range & Subnet Mask Calculator

/32 (1 Host) /31 (2 Hosts – PTP) /30 (4 Hosts – 2 Usable) /29 (8 Hosts – 6 Usable) /28 (16 Hosts – 14 Usable) /27 (32 Hosts – 30 Usable) /26 (64 Hosts – 62 Usable) /25 (128 Hosts – 126 Usable) /24 (256 Hosts – 254 Usable) /23 (512 Hosts – 510 Usable) /22 (1024 Hosts – 1022 Usable) /21 (2048 Hosts – 2046 Usable) /20 (4096 Hosts – 4094 Usable) /19 (8192 Hosts – 8190 Usable) /18 (16384 Hosts – 16382 Usable) /17 (32768 Hosts – 32766 Usable) /16 (65536 Hosts – 65534 Usable) /8 (16.7M Hosts)

Calculation Results

Network Address:
Broadcast Address:
Usable Host Range:
Total Usable Hosts:
Subnet Mask:
CIDR Notation:
Please enter a valid IPv4 address (e.g., 192.168.1.1).

What is an IP Range and Subnet Mask?

An IP Range Calculator is an essential tool for network administrators and engineers. It determines the boundaries of a specific network segment based on an IP address and a subnet mask (represented in CIDR notation). Understanding these values is crucial for configuring routers, firewalls, and assigning static IP addresses within a local area network (LAN).

Core Components of Subnetting

  • Network Address: The first address in the subnet. It identifies the network itself and cannot be assigned to a host device.
  • Broadcast Address: The last address in the subnet. It is used to send data to every device on that specific network.
  • Usable IP Range: The set of addresses between the Network and Broadcast addresses that can be assigned to devices like computers, printers, and servers.
  • Subnet Mask: A 32-bit number that masks an IP address and divides the IP address into network address and host address parts.

How the Calculation Works

To calculate an IP range, the calculator performs a bitwise AND operation between the IP address and the subnet mask. This reveals the network address. To find the broadcast address, the calculator performs an OR operation between the network address and the bitwise NOT of the subnet mask.

Example Calculation

If you have the IP 192.168.1.10 with a /24 subnet mask:

  1. Subnet Mask: 255.255.255.0
  2. Network Address: 192.168.1.0
  3. First Usable Host: 192.168.1.1
  4. Last Usable Host: 192.168.1.254
  5. Broadcast Address: 192.168.1.255
  6. Total Usable Hosts: 254

Why use CIDR?

Classless Inter-Domain Routing (CIDR) replaced the old Class A, B, and C system. It allows for more efficient allocation of IP addresses. Instead of being stuck with fixed sizes, CIDR allows networks to be any size required by appending a slash followed by a number (like /24) representing the number of shared initial bits in the address.

function calculateSubnet() { var ipInput = document.getElementById('ipAddress').value.trim(); var cidr = parseInt(document.getElementById('cidrMask').value); var resultsArea = document.getElementById('resultsArea'); var errorArea = document.getElementById('errorArea'); // Reset UI resultsArea.style.display = 'none'; errorArea.style.display = 'none'; // Validate IP var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; var match = ipPattern.exec(ipInput); if (!match) { errorArea.style.display = 'block'; return; } var octets = []; for (var i = 1; i <= 4; i++) { var octet = parseInt(match[i]); if (octet 255) { errorArea.style.display = 'block'; return; } octets.push(octet); } // Convert IP to 32-bit integer var ipInt = (octets[0] <>> 0; ipInt += (octets[1] <>> 0; ipInt += (octets[2] <>> 0; ipInt += (octets[3]) >>> 0; // Calculate Mask var maskInt = 0; if (cidr > 0) { maskInt = (0xFFFFFFFF <>> 0; } // Network and Broadcast var networkInt = (ipInt & maskInt) >>> 0; var broadcastInt = (networkInt | (~maskInt)) >>> 0; // Helper to convert Int to IP string function intToIp(i) { return ((i >>> 24) & 0xFF) + "." + ((i >>> 16) & 0xFF) + "." + ((i >>> 8) & 0xFF) + "." + (i & 0xFF); } // Host calculations var firstUsable = networkInt + 1; var lastUsable = broadcastInt – 1; var totalHosts = 0; if (cidr === 32) { firstUsable = networkInt; lastUsable = networkInt; totalHosts = 1; } else if (cidr === 31) { firstUsable = networkInt; lastUsable = broadcastInt; totalHosts = 2; } else { totalHosts = broadcastInt – networkInt – 1; if (totalHosts < 0) totalHosts = 0; } // Update DOM document.getElementById('resNetwork').innerText = intToIp(networkInt); document.getElementById('resBroadcast').innerText = intToIp(broadcastInt); if (cidr <= 30) { document.getElementById('resRange').innerText = intToIp(firstUsable) + " – " + intToIp(lastUsable); document.getElementById('resHosts').innerText = totalHosts.toLocaleString(); } else if (cidr === 31) { document.getElementById('resRange').innerText = intToIp(networkInt) + ", " + intToIp(broadcastInt); document.getElementById('resHosts').innerText = "2 (Point-to-Point)"; } else { document.getElementById('resRange').innerText = intToIp(networkInt); document.getElementById('resHosts').innerText = "1"; } document.getElementById('resMask').innerText = intToIp(maskInt); document.getElementById('resCidr').innerText = "/" + cidr; resultsArea.style.display = 'block'; }

Leave a Comment