Calculator Subnetting

.subnet-calc-container { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; max-width: 800px; 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); } .subnet-calc-container h2 { color: #2c3e50; text-align: center; margin-bottom: 25px; font-size: 28px; } .input-group { margin-bottom: 20px; display: flex; flex-wrap: wrap; gap: 15px; } .input-field { flex: 1; min-width: 200px; } .input-field label { display: block; margin-bottom: 8px; font-weight: 600; color: #34495e; } .input-field input, .input-field select { width: 100%; padding: 12px; border: 1px solid #ced4da; border-radius: 6px; font-size: 16px; box-sizing: border-box; } .calc-btn { width: 100%; background-color: #007bff; color: white; padding: 15px; border: none; border-radius: 6px; font-size: 18px; font-weight: bold; cursor: pointer; transition: background-color 0.2s; } .calc-btn:hover { background-color: #0056b3; } #subnet-results { margin-top: 30px; display: none; padding: 20px; background-color: #f8f9fa; border-radius: 8px; border-left: 5px solid #007bff; } .result-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #dee2e6; } .result-row:last-child { border-bottom: none; } .result-label { font-weight: 600; color: #495057; } .result-value { font-family: monospace; color: #212529; font-size: 16px; } .error-msg { color: #dc3545; text-align: center; margin-top: 10px; display: none; font-weight: bold; } .article-section { margin-top: 40px; line-height: 1.6; color: #333; } .article-section h3 { color: #2c3e50; border-bottom: 2px solid #007bff; padding-bottom: 5px; margin-top: 30px; } .article-section table { width: 100%; border-collapse: collapse; margin: 20px 0; } .article-section th, .article-section td { border: 1px solid #ddd; padding: 12px; text-align: left; } .article-section th { background-color: #f2f2f2; }

Advanced IPv4 Subnet Calculator

/32 (1 Host) /31 (2 Hosts – P2P) /30 (4 Hosts) /29 (8 Hosts) /28 (16 Hosts) /27 (32 Hosts) /26 (64 Hosts) /25 (128 Hosts) /24 (256 Hosts) /23 (512 Hosts) /22 (1024 Hosts) /21 (2048 Hosts) /20 (4096 Hosts) /19 (8192 Hosts) /18 (16384 Hosts) /17 (32768 Hosts) /16 (65536 Hosts) /15 (131072 Hosts) /14 (262144 Hosts) /13 (524288 Hosts) /12 (1048576 Hosts) /11 (2097152 Hosts) /10 (4194304 Hosts) /9 (8388608 Hosts) /8 (16777216 Hosts)
Invalid IP Address format. Please use 0.0.0.0 format.
Network Address:
Usable Host Range:
Broadcast Address:
Total Number of Hosts:
Usable Number of Hosts:
Subnet Mask:
Wildcard Mask:
Binary ID:

What is Subnetting?

Subnetting is the process of dividing a large network into smaller, manageable sub-networks or "subnets." By using a Subnetting Calculator, network administrators can efficiently allocate IP addresses, reduce network congestion, and improve security. Subnetting works by borrowing bits from the host portion of an IP address to create a network identifier.

Key Subnetting Terms Explained

  • IP Address: A unique numerical label assigned to each device connected to a computer network.
  • Subnet Mask: A 32-bit number that masks an IP address and divides the IP address into network address and host address.
  • CIDR (Classless Inter-Domain Routing): A method for allocating IP addresses and IP routing that replaced the older Class A, B, and C system. It is denoted by a slash followed by the number of bits in the network prefix (e.g., /24).
  • Wildcard Mask: The inverse of a subnet mask, often used in Access Control Lists (ACLs).
  • Broadcast Address: A special IP address used to transmit messages to all nodes on a specific network.

Common Subnet Masks Table

CIDR Subnet Mask Total Hosts Usable Hosts
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/30255.255.255.25242

Why Use This Calculator?

Calculating subnets manually involves binary math which is prone to human error. This tool provides instant results for Network ID, Broadcast ID, and Usable IP ranges, ensuring your network configuration is accurate. Whether you are studying for your CCNA or setting up a home lab, this IPv4 subnetting tool handles the complex bitwise logic for you.

function calculateSubnet() { var ipStr = document.getElementById('ipAddress').value.trim(); var cidr = parseInt(document.getElementById('cidrMask').value); var errorDiv = document.getElementById('error'); var resultDiv = document.getElementById('subnet-results'); // Validation var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; var match = ipStr.match(ipPattern); if (!match) { errorDiv.style.display = 'block'; resultDiv.style.display = 'none'; return; } var octets = match.slice(1).map(function(o) { return parseInt(o); }); for (var i = 0; i 255) { errorDiv.style.display = 'block'; resultDiv.style.display = 'none'; return; } } errorDiv.style.display = 'none'; resultDiv.style.display = 'block'; // Convert IP to 32-bit integer var ipInt = ((octets[0] <>> 0) | ((octets[1] <>> 0) | ((octets[2] <>> 0) | (octets[3] >>> 0); // Calculate Subnet Mask var maskInt = 0; if (cidr > 0) { maskInt = (0xFFFFFFFF <>> 0; } // Network and Broadcast logic var networkInt = (ipInt & maskInt) >>> 0; var wildcardInt = (~maskInt) >>> 0; var broadcastInt = (networkInt | wildcardInt) >>> 0; // Helper to convert Int to IP String function intToIp(int) { return ((int >>> 24) & 0xFF) + "." + ((int >>> 16) & 0xFF) + "." + ((int >>> 8) & 0xFF) + "." + (int & 0xFF); } // Helper for Binary Display function intToBin(int) { var str = (int >>> 0).toString(2); while (str.length 0 ? usableHosts.toLocaleString() : 0; document.getElementById('resRange').innerText = firstHost + " – " + lastHost; document.getElementById('resBinary').innerText = intToBin(networkInt); }

Leave a Comment