Calculator Ip Address

IP Address & Subnet Calculator

/32 (255.255.255.255 – Host) /31 (255.255.255.254) /30 (255.255.255.252 – Point-to-Point) /29 (255.255.255.248) /28 (255.255.255.240) /27 (255.255.255.224) /26 (255.255.255.192) /25 (255.255.255.128) /24 (255.255.255.0 – Class C) /23 (255.255.254.0) /22 (255.255.252.0) /21 (255.255.248.0) /20 (255.255.240.0) /19 (255.255.224.0) /18 (255.255.192.0) /17 (255.255.128.0) /16 (255.255.0.0 – Class B) /15 (255.254.0.0) /14 (255.252.0.0) /13 (255.248.0.0) /12 (255.240.0.0) /11 (255.224.0.0) /10 (255.192.0.0) /9 (255.128.0.0) /8 (255.0.0.0 – Class A) /7 (254.0.0.0) /6 (252.0.0.0) /5 (248.0.0.0) /4 (240.0.0.0) /3 (224.0.0.0) /2 (192.0.0.0) /1 (128.0.0.0)

Calculation Results

Network Address:
Broadcast Address:
Usable Host Range:
Total Number of Hosts:
Usable Number of Hosts:
Subnet Mask:
Wildcard Mask:
Invalid IP Address format. Please enter a valid IPv4 address (e.g., 172.16.254.1).

Understanding IP Addresses and Subnetting

An IP address calculator is an essential tool for network administrators and IT professionals. It allows you to determine the boundaries of a network, calculate the number of available host addresses, and identify the broadcast address for a specific subnet.

What is an IP Address?

An IPv4 address consists of 32 bits, typically represented as four "octets" in decimal format (e.g., 192.168.0.1). These bits are divided into two parts: the Network Portion and the Host Portion.

The Role of the Subnet Mask

The subnet mask determines which part of the IP address belongs to the network and which part is available for devices (hosts). Using CIDR (Classless Inter-Domain Routing) notation, such as /24, we indicate that the first 24 bits are reserved for the network.

  • Network Address: The first address in the range, used to identify the network itself.
  • Broadcast Address: The last address in the range, used to send data to all hosts on the subnet.
  • Usable Hosts: Calculated as 2(32 – CIDR) – 2. We subtract two because the Network and Broadcast addresses cannot be assigned to individual devices.

Example IP Calculation

If you have an IP address 192.168.1.10 with a subnet mask of /24 (255.255.255.0):

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

This calculator helps you automate these binary conversions instantly, ensuring network accuracy and preventing IP conflicts in your local or wide area networks.

function ipToLong(ip) { var d = ip.split('.'); return ((((((+d[0]) * 256) + (+d[1])) * 256) + (+d[2])) * 256) + (+d[3]); } function longToIp(l) { return ((l >>> 24) + '.' + (l >> 16 & 255) + '.' + (l >> 8 & 255) + '.' + (l & 255)); } function calculateIP() { var ipInput = document.getElementById('ipAddress').value.trim(); var cidr = parseInt(document.getElementById('cidr').value); var errorDiv = document.getElementById('error-msg'); var resultDiv = document.getElementById('results'); // Validate IP Address regex var ipPattern = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; if (!ipPattern.test(ipInput)) { errorDiv.style.display = 'block'; resultDiv.style.display = 'none'; return; } errorDiv.style.display = 'none'; resultDiv.style.display = 'block'; var ipLong = ipToLong(ipInput); // Calculate Mask var maskLong = 0; if (cidr > 0) { maskLong = (0xFFFFFFFF <>> 0; } var networkLong = (ipLong & maskLong) >>> 0; var wildcardLong = (~maskLong) >>> 0; var broadcastLong = (networkLong | wildcardLong) >>> 0; var totalHosts = Math.pow(2, (32 – cidr)); var usableHosts = (cidr <= 30) ? (totalHosts – 2) : (cidr == 31 ? 2 : 1); var firstHost = ""; var lastHost = ""; if (cidr <= 30) { firstHost = longToIp(networkLong + 1); lastHost = longToIp(broadcastLong – 1); } else if (cidr == 31) { firstHost = longToIp(networkLong); lastHost = longToIp(broadcastLong); } else { firstHost = longToIp(networkLong); lastHost = longToIp(networkLong); } // Update UI document.getElementById('resNetwork').innerText = longToIp(networkLong) + " /" + cidr; document.getElementById('resBroadcast').innerText = longToIp(broadcastLong); document.getElementById('resMask').innerText = longToIp(maskLong); document.getElementById('resWildcard').innerText = longToIp(wildcardLong); document.getElementById('resTotal').innerText = totalHosts.toLocaleString(); document.getElementById('resUsable').innerText = usableHosts < 0 ? 0 : usableHosts.toLocaleString(); if (cidr <= 31) { document.getElementById('resRange').innerText = firstHost + " – " + lastHost; } else { document.getElementById('resRange').innerText = firstHost + " (Single Host)"; } }

Leave a Comment