Subnet Calculator

Subnet Calculator
/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 Results:
Network Address:
Usable Host Range:
Broadcast Address:
Total Usable Hosts:
Subnet Mask:
Wildcard Mask:
function intToIp(i){return ((i>>>24)&0xFF)+'.'+((i>>>16)&0xFF)+'.'+((i>>>8)&0xFF)+'.'+(i&0xFF);}function ipToInt(o1,o2,o3,o4){return ((+o1)<<24|(+o2)<<16|(+o3)<>>0;}function toBin(i){var s=(i>>>0).toString(2);while(s.length<32)s='0'+s;return s.match(/.{8}/g).join('.');}function calculateSubnet(){var o1=document.getElementById('oct1').value;var o2=document.getElementById('oct2').value;var o3=document.getElementById('oct3').value;var o4=document.getElementById('oct4').value;var cidr=parseInt(document.getElementById('cidr').value);if(o1255||o2255||o3255||o4255){alert('Please enter valid octets (0-255)');return;}var ip=ipToInt(o1,o2,o3,o4);var mask=(cidr===0)?0:(0xFFFFFFFF<>>0;var network=(ip&mask)>>>0;var broadcast=(network|(~mask))>>>0;var wildcard=(~mask)>>>0;var totalHosts=(cidr>=31)?0:Math.pow(2,32-cidr)-2;document.getElementById('resNetwork').innerHTML=intToIp(network);document.getElementById('resMask').innerHTML=intToIp(mask);document.getElementById('resBroadcast').innerHTML=intToIp(broadcast);document.getElementById('resWildcard').innerHTML=intToIp(wildcard);if(cidr>=31){document.getElementById('resRange').innerHTML='N/A';document.getElementById('resHosts').innerHTML='0′;}else{document.getElementById('resRange').innerHTML=intToIp(network+1)+' – '+intToIp(broadcast-1);document.getElementById('resHosts').innerHTML=totalHosts.toLocaleString();}if(document.getElementById('steps').checked){document.getElementById('binaryRow').style.display='table-row';document.getElementById('resBinary').innerHTML='Binary Representation:
IP: '+toBin(ip)+'
Mask: '+toBin(mask)+'
Net: '+toBin(network);}else{document.getElementById('binaryRow').style.display='none';}}

Calculator Use

The subnet calculator is an essential tool for network administrators and IT students to quickly determine critical network parameters. By entering an IPv4 address and selecting a CIDR prefix (or subnet mask), you can instantly find the network boundary, usable host addresses, and broadcast identity. This tool is specifically designed to help design networks, troubleshoot connectivity issues, and optimize IP address allocation.

To use this calculator, simply follow these steps:

IP Address
Enter the four octets of your IPv4 address (e.g., 192, 168, 1, 10).
Subnet Mask / CIDR
Select the prefix length (like /24) or the corresponding decimal mask (like 255.255.255.0).
Show Binary Details
Check this box if you want to see the underlying bitwise logic used by routers.

How It Works

Subnetting works by "borrowing" bits from the host portion of an IP address to create smaller sub-networks. This improves network performance and security. The subnet calculator uses bitwise operations to extract data from your inputs. The logic follows these primary formulas:

Network ID = IP Address AND Subnet Mask

  • AND Operation: Only bits that are "1" in both the IP and the Mask remain "1" in the Network ID.
  • Broadcast ID: Calculated by taking the Network ID and setting all host bits to "1".
  • Usable Hosts: Calculated as 2^(32 – CIDR) – 2. We subtract 2 because the first address is the Network ID and the last is the Broadcast ID.

Subnet Calculation Example

Example: You are assigned the IP 10.0.0.5 with a /26 prefix. You need to find the network range.

Step-by-step solution:

  1. Identify CIDR: /26 means the mask has 26 ones followed by 6 zeros (255.255.255.192).
  2. Find Network ID: Perform bitwise AND on 10.0.0.5 and 255.255.255.192. Result = 10.0.0.0.
  3. Calculate Total Hosts: 2^(32-26) = 2^6 = 64. Usable hosts = 64 – 2 = 62.
  4. Find Broadcast: 10.0.0.0 + 63 = 10.0.0.63.
  5. Result: Usable range is 10.0.0.1 to 10.0.0.62.

Common Questions

What is a Wildcard Mask?

A wildcard mask is the inverse of a subnet mask. It is primarily used in Access Control Lists (ACLs) in Cisco routers. If your subnet mask is 255.255.255.0, your wildcard mask is 0.0.0.255.

Why subtract 2 from total hosts?

In standard IPv4 networking, the very first address in a subnet is reserved to identify the network itself (Network ID), and the very last address is reserved for broadcasting messages to all devices on that subnet (Broadcast ID). Neither can be assigned to a computer or printer.

What is CIDR?

CIDR stands for Classless Inter-Domain Routing. It replaced the old "Class A, B, C" system, allowing for more flexible network sizes. It is represented by the "slash" notation (e.g., /24), indicating how many bits are used for the network portion.

Leave a Comment