Calculator Ip Subnetting

.subnet-calc-container { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; max-width: 800px; margin: 20px auto; padding: 25px; border: 1px solid #e1e1e1; border-radius: 8px; background-color: #f9f9f9; box-shadow: 0 4px 6px rgba(0,0,0,0.05); } .subnet-calc-container h2 { color: #2c3e50; margin-top: 0; text-align: center; font-size: 24px; } .input-group { margin-bottom: 20px; } .input-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #333; } .input-group input, .input-group select { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 16px; } .calc-btn { width: 100%; background-color: #0073aa; color: white; padding: 15px; border: none; border-radius: 4px; cursor: pointer; font-size: 18px; font-weight: bold; transition: background-color 0.3s; } .calc-btn:hover { background-color: #005177; } .results-section { margin-top: 30px; display: none; background: #fff; padding: 20px; border-radius: 6px; border: 1px solid #d1d1d1; } .results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; } .result-item { padding: 10px; border-bottom: 1px solid #eee; } .result-label { font-size: 12px; text-transform: uppercase; color: #777; margin-bottom: 5px; } .result-value { font-weight: bold; color: #222; word-break: break-all; } .article-section { margin-top: 40px; line-height: 1.6; color: #444; } .article-section h3 { color: #2c3e50; border-left: 4px solid #0073aa; padding-left: 10px; } .error-msg { color: #d63031; font-weight: bold; margin-bottom: 15px; display: none; }

IPv4 Subnet Calculator

Please enter a valid IP address.
/32 (255.255.255.255) /31 (255.255.255.254) /30 (255.255.255.252) /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) /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) /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)
Network Address
Broadcast Address
Usable Host Range
Total Usable Hosts
Subnet Mask
Wildcard Mask
Binary ID
CIDR Notation

What is IP Subnetting?

IP Subnetting is the practice of dividing a single physical network into two or more logical sub-networks (subnets). This process is vital for managing IP addresses efficiently and improving network performance and security. By breaking a large network into smaller segments, you reduce broadcast traffic and can apply specific security policies to different departments or areas of your organization.

How to Calculate a Subnet

To calculate a subnet, you must perform a bitwise AND operation between the IP address and the Subnet Mask. This determines the Network Address. The Broadcast Address is calculated by setting all host bits in the network to 1. The range between the Network address and Broadcast address (excluding those two) provides the Usable Host Addresses.

CIDR Notation Explained

CIDR (Classless Inter-Domain Routing) notation simplifies the representation of subnet masks. For example, instead of writing 255.255.255.0, we use /24. The number 24 represents the number of leading '1' bits in the subnet mask. Our calculator supports masks from /8 (Class A) all the way down to /32 (Single Host).

Example Calculation

If you have an IP address 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 Range: 192.168.1.1 to 192.168.1.254
  • Total Hosts: 254
function numToDot(n) { return [ (n >>> 24) & 0xFF, (n >>> 16) & 0xFF, (n >>> 8) & 0xFF, n & 0xFF ].join('.'); } function dotToNum(dot) { var parts = dot.split('.'); if (parts.length !== 4) return null; var res = 0; for (var i = 0; i < 4; i++) { var p = parseInt(parts[i]); if (isNaN(p) || p 255) return null; res = (res <>> 0; } function numToBin(n) { var bin = (n >>> 0).toString(2); while (bin.length < 32) bin = '0' + bin; return bin.match(/.{1,8}/g).join('.'); } function calculateSubnet() { var ipStr = document.getElementById('ipAddress').value.trim(); var cidr = parseInt(document.getElementById('cidrMask').value); var errorDiv = document.getElementById('errorMessage'); var resultsDiv = document.getElementById('results'); var ipNum = dotToNum(ipStr); if (ipNum === null) { errorDiv.style.display = 'block'; resultsDiv.style.display = 'none'; return; } errorDiv.style.display = 'none'; resultsDiv.style.display = 'block'; var maskNum = (0xFFFFFFFF <>> 0; if (cidr === 0) maskNum = 0; // handle /0 if needed, though dropdown starts at /8 var wildcardNum = (~maskNum) >>> 0; var networkNum = (ipNum & maskNum) >>> 0; var broadcastNum = (networkNum | wildcardNum) >>> 0; var hostCount = 0; var rangeStr = ""; if (cidr === 32) { hostCount = 1; rangeStr = numToDot(networkNum); } else if (cidr === 31) { hostCount = 2; rangeStr = numToDot(networkNum) + " – " + numToDot(broadcastNum); } else { hostCount = Math.pow(2, (32 – cidr)) – 2; rangeStr = numToDot(networkNum + 1) + " – " + numToDot(broadcastNum – 1); } document.getElementById('resNetwork').innerText = numToDot(networkNum); document.getElementById('resBroadcast').innerText = numToDot(broadcastNum); document.getElementById('resRange').innerText = rangeStr; document.getElementById('resHosts').innerText = hostCount.toLocaleString(); document.getElementById('resMask').innerText = numToDot(maskNum); document.getElementById('resWildcard').innerText = numToDot(wildcardNum); document.getElementById('resBinary').innerText = numToBin(ipNum); document.getElementById('resCIDR').innerText = "/" + cidr; }

Leave a Comment