Ip Netmask Calculator

IP Netmask & Subnet Calculator

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

Calculation Results

Network Address:
Broadcast Address:
Usable Host Range:
Total Hosts:
Usable Hosts:
Wildcard Mask:
Binary Mask:

Understanding IP Subnetting and Netmasks

An IP Netmask calculator is an essential tool for network administrators and IT professionals. It allows you to determine the boundaries of a network, the number of available host addresses, and identify the network and broadcast addresses for any given IPv4 address and CIDR prefix.

What is a Subnet Mask?

A subnet mask is a 32-bit number that masks an IP address and divides the IP address into network address and host address. It is used by the TCP/IP protocol to determine whether a host is on the local subnet or on a remote network.

CIDR Notation Explained

CIDR (Classless Inter-Domain Routing) notation is a compact way to represent an IP address and its associated routing prefix. For example, 192.168.1.0/24 represents the IP address and its subnet mask 255.255.255.0. The "/24" indicates that the first 24 bits of the address are the network portion.

Example Calculation

If you have an IP address 10.0.0.50 with a /26 mask (255.255.255.192):

  • Network Address: 10.0.0.0 (The start of the block)
  • Broadcast Address: 10.0.0.63 (The end of the block)
  • Usable Hosts: 10.0.0.1 to 10.0.0.62
  • Total Hosts: 64 (2^6)
  • Usable Hosts: 62 (Total – Network – Broadcast)

Why use this tool?

Manual binary math for subnetting is prone to errors. This calculator provides instant results for planning network topology, configuring routers, or troubleshooting connectivity issues. It supports all standard IPv4 CIDR ranges from /1 to /32.

function ipToInt(ip) { var parts = ip.split('.'); if (parts.length !== 4) return null; var res = 0; for (var i = 0; i < 4; i++) { var part = parseInt(parts[i]); if (isNaN(part) || part 255) return null; res = (res <>> 0; } function intToIp(int) { return ((int >>> 24) & 0xFF) + '.' + ((int >>> 16) & 0xFF) + '.' + ((int >>> 8) & 0xFF) + '.' + (int & 0xFF); } function getMaskFromCidr(cidr) { return (0xFFFFFFFF <>> 0; } function calculateSubnet() { var ipInput = document.getElementById("ipAddress").value.trim(); var cidr = parseInt(document.getElementById("netmask").value); var errorDiv = document.getElementById("error-msg"); var resultDiv = document.getElementById("results"); errorDiv.style.display = "none"; resultDiv.style.display = "none"; var ip = ipToInt(ipInput); if (ip === null) { errorDiv.innerText = "Please enter a valid IPv4 address (e.g., 192.168.1.1)."; errorDiv.style.display = "block"; return; } var mask = getMaskFromCidr(cidr); var network = (ip & mask) >>> 0; var wildcard = (~mask) >>> 0; var broadcast = (network | wildcard) >>> 0; var totalHosts = Math.pow(2, 32 – cidr); var usableHosts = cidr <= 30 ? totalHosts – 2 : (cidr === 31 ? 2 : 1); var firstHost = (cidr <= 30) ? network + 1 : network; var lastHost = (cidr <= 30) ? broadcast – 1 : broadcast; // Fill results document.getElementById("resNetwork").innerText = intToIp(network) + " /" + cidr; document.getElementById("resBroadcast").innerText = intToIp(broadcast); if (cidr <= 30) { document.getElementById("resRange").innerText = intToIp(firstHost) + " – " + intToIp(lastHost); } else if (cidr === 31) { document.getElementById("resRange").innerText = intToIp(network) + " – " + intToIp(broadcast); } else { document.getElementById("resRange").innerText = intToIp(network) + " (Host Only)"; } document.getElementById("resTotalHosts").innerText = totalHosts.toLocaleString(); document.getElementById("resUsableHosts").innerText = usableHosts >> 0).toString(2).padStart(32, '0'); var formattedBinary = binaryStr.match(/.{1,8}/g).join('.'); document.getElementById("resBinaryMask").innerText = formattedBinary; resultDiv.style.display = "block"; }

Leave a Comment