The Comprehensive CIDR Subnetting Guide: Network Masks, Broadcast IPs & Usable Hosts
Master IP subnetting from /8 to /32. Learn how CIDR notation simplifies network routing tables and how to calculate host ranges with zero guesswork.
ToolByte Network Engineering
Network Infrastructure Engineer
From Ancient Classful Networks to Modern CIDR
Calculate network ID, broadcast IP, wildcard mask, and usable host count for any IPv4 address and CIDR prefix.
The Core Subnetting Mathematical Formulas
export function calculateSubnet(ipStr: string, prefix: number) {
const ipParts = ipStr.split('.').map(Number);
const ipInt = (ipParts[0] << 24) | (ipParts[1] << 16) | (ipParts[2] << 8) | ipParts[3];
// Generate 32-bit subnet mask
const maskInt = prefix === 0 ? 0 : (~0 << (32 - prefix));
// Bitwise calculations
const networkInt = (ipInt & maskInt) >>> 0;
const broadcastInt = (networkInt | (~maskInt >>> 0)) >>> 0;
const totalHosts = Math.pow(2, 32 - prefix);
const usableHosts = prefix >= 31 ? 0 : totalHosts - 2;
return { networkInt, broadcastInt, totalHosts, usableHosts };
}Ready to use the full CIDR Subnet Calculator?
Experience lightning-fast client-side execution with zero cloud storage, zero tracking, and complete data privacy.
Frequently Asked Questions
Related Developer Tools
Visual IPv4 Subnet & CIDR Mask Calculator
Compute subnet masks, usable host ranges, broadcast addresses, and 32-bit binary representations in real time.
VLSM Subnet Calculator & Subnet Partitioning Studio
Optimal Variable-Length Subnet Mask allocation with zero wasted host addresses and visual block map.
Universal IPv4 Subnet & Bitwise Calculator
Calculate network bounds, wildcard masks, usable hosts, and 32-bit color-coded binary breakdowns.
IPv6 Subnet & Hex Address Expander
Expand compressed IPv6 addresses, compute 128-bit prefix boundaries, and inspect RFC scopes.