Ip Address Subnet Calculator

.subnet-calc-container { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; max-width: 850px; margin: 20px auto; padding: 25px; border: 1px solid #e1e1e1; border-radius: 12px; background-color: #ffffff; box-shadow: 0 4px 6px rgba(0,0,0,0.05); color: #333; } .subnet-calc-container h2 { color: #1a73e8; margin-top: 0; font-size: 28px; text-align: center; } .calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 25px; } .input-group { margin-bottom: 15px; } .input-group label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: #555; } .ip-input-wrapper { display: flex; align-items: center; gap: 5px; } .ip-input-wrapper input { width: 60px; padding: 10px; border: 1px solid #ccc; border-radius: 4px; text-align: center; font-size: 16px; } .subnet-calc-container select, .subnet-calc-container input[type="number"] { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; box-sizing: border-box; } .calc-btn { width: 100%; background-color: #1a73e8; color: white; padding: 14px; border: none; border-radius: 6px; font-size: 18px; font-weight: bold; cursor: pointer; transition: background 0.3s; margin-top: 10px; } .calc-btn:hover { background-color: #1557b0; } .results-card { background-color: #f8f9fa; padding: 20px; border-radius: 8px; border-left: 5px solid #1a73e8; margin-top: 25px; display: none; } .results-card h3 { margin-top: 0; font-size: 20px; color: #333; border-bottom: 1px solid #dee2e6; padding-bottom: 10px; } .result-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dotted #ddd; } .result-row:last-child { border-bottom: none; } .result-label { font-weight: 600; color: #666; } .result-value { font-family: "Courier New", Courier, monospace; font-weight: bold; color: #d93025; } .article-section { margin-top: 40px; line-height: 1.6; color: #444; } .article-section h3 { color: #222; margin-top: 25px; } .article-section p { margin-bottom: 15px; } .example-box { background: #fff3cd; padding: 15px; border-radius: 6px; border-left: 4px solid #ffc107; margin: 20px 0; } @media (max-width: 600px) { .calc-grid { grid-template-columns: 1fr; } .ip-input-wrapper input { width: 50px; } }

IP 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)

Network Information

Network Address:
Usable Host Range:
Broadcast Address:
Total Number of Hosts:
Usable Number of Hosts:
Subnet Mask:
Wildcard Mask:
CIDR Notation:

Understanding IP Subnetting

Subnetting is the process of dividing a single physical network into multiple logical sub-networks (subnets). This technique is essential for efficient IP address management, reducing network congestion, and enhancing security. By breaking down a large network, IT professionals can group devices logically based on department, floor, or function.

How to Calculate Subnet Details

Calculating a subnet involves bitwise operations on the IP address and the subnet mask. The subnet mask determines which part of the IP address represents the network ID and which part represents the host ID.

  • Network Address: This is the first address in the subnet. It is found by performing a bitwise AND operation between the IP address and the subnet mask.
  • Broadcast Address: This is the last address in the subnet. It is used to send data to all hosts on that network.
  • Usable Hosts: In most subnets, the first address (Network) and last address (Broadcast) cannot be assigned to devices, so the number of usable hosts is 2(32 – prefix) – 2.
Example Calculation:
If you have an IP of 192.168.1.10 with a /24 mask:
– Subnet Mask: 255.255.255.0
– Network Address: 192.168.1.0
– Broadcast Address: 192.168.1.255
– Usable Hosts: 192.168.1.1 to 192.168.1.254 (254 hosts total)

Why Use a Subnet Calculator?

Manual subnetting requires converting decimal numbers to binary, performing bitwise math, and converting back to decimal. While critical for CCNA or Network+ exams, using a calculator in real-world scenarios prevents configuration errors that could lead to network downtime or IP address conflicts. It provides immediate visibility into CIDR notation, wildcard masks, and usable host ranges for complex networks like /27 or /22.

function intToIP(int) { var part1 = (int >>> 24) & 255; var part2 = (int >>> 16) & 255; var part3 = (int >>> 8) & 255; var part4 = int & 255; return part1 + "." + part2 + "." + part3 + "." + part4; } function calculateSubnet() { var o1 = parseInt(document.getElementById("octet1").value); var o2 = parseInt(document.getElementById("octet2").value); var o3 = parseInt(document.getElementById("octet3").value); var o4 = parseInt(document.getElementById("octet4").value); var cidr = parseInt(document.getElementById("cidr_mask").value); // Validation if (isNaN(o1) || isNaN(o2) || isNaN(o3) || isNaN(o4) || o1 255 || o2 255 || o3 255 || o4 255) { alert("Please enter a valid IPv4 address (0-255 for each octet)."); return; } // Convert IP to 32-bit integer var ipInt = ((o1 <>> 0) | (o2 << 16) | (o3 < 0) { maskInt = (0xFFFFFFFF <>> 0; } // Network Address var networkInt = (ipInt & maskInt) >>> 0; // Wildcard Mask var wildcardInt = (~maskInt) >>> 0; // Broadcast Address var broadcastInt = (networkInt | wildcardInt) >>> 0; // Hosts var totalHosts = Math.pow(2, (32 – cidr)); var usableHosts = (cidr >= 31) ? 0 : (totalHosts – 2); // Ranges var rangeStart = ""; var rangeEnd = ""; if (cidr <= 30) { rangeStart = intToIP(networkInt + 1); rangeEnd = intToIP(broadcastInt – 1); } else if (cidr === 31) { rangeStart = intToIP(networkInt); rangeEnd = intToIP(broadcastInt); usableHosts = 2; // Special case for /31 point-to-point } else { rangeStart = intToIP(networkInt); rangeEnd = intToIP(networkInt); usableHosts = 1; } // Display Results document.getElementById("resNetwork").innerText = intToIP(networkInt); document.getElementById("resBroadcast").innerText = intToIP(broadcastInt); document.getElementById("resRange").innerText = rangeStart + " – " + rangeEnd; document.getElementById("resTotalHosts").innerText = totalHosts.toLocaleString(); document.getElementById("resUsableHosts").innerText = usableHosts.toLocaleString(); document.getElementById("resMask").innerText = intToIP(maskInt); document.getElementById("resWildcard").innerText = intToIP(wildcardInt); document.getElementById("resCIDR").innerText = "/" + cidr; document.getElementById("subnetResults").style.display = "block"; }

Leave a Comment