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
/24
255.255.255.0
256
254
/25
255.255.255.128
128
126
/26
255.255.255.192
64
62
/27
255.255.255.224
32
30
/30
255.255.255.252
4
2
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);
}