Testing Environment: Our tools are currently under heavy testing. You may experience slower performance or temporary issues.

🌐

IPv4 Subnet Calculator

Calculate IPv4 subnets, CIDR notation, and network ranges

0 characters

About IPv4 Subnet Calculator

Calculate IPv4 subnets, CIDR notation, network addresses, broadcast addresses, and available host ranges. This comprehensive subnet calculator helps network administrators plan IP address allocations and understand network segmentation.

  • Calculate subnet masks and CIDR notation
  • Determine network and broadcast addresses
  • Find available host ranges
  • Support for variable length subnet masking (VLSM)
  • Network planning and documentation tools

How to Use IPv4 Subnet Calculator

  1. Enter IP Address - Input any valid IPv4 address (e.g., 192.168.1.1)
  2. Specify Subnet - Enter subnet mask or CIDR prefix (e.g., /24 or 255.255.255.0)
  3. Calculate - Get detailed subnet information including network range
  4. View Results - See network address, broadcast address, and host range

Advertisement

AdSense Banner Ad Placeholder

Frequently Asked Questions

What is subnet masking?

Subnet masking is a technique that divides a network into smaller subnetworks. It uses a subnet mask to determine which portion of an IP address identifies the network and which identifies the host.

What is CIDR notation?

CIDR (Classless Inter-Domain Routing) notation uses a slash followed by a number to indicate the network prefix length. For example, /24 means the first 24 bits are the network portion.

How do I calculate the number of hosts?

The number of available hosts is 2^(host bits) - 2. The -2 accounts for the network address (first) and broadcast address (last), which cannot be assigned to hosts.

What are network and broadcast addresses?

The network address identifies the subnet itself (all host bits are 0), while the broadcast address is used to send messages to all hosts in the subnet (all host bits are 1).

What is Variable Length Subnet Masking (VLSM)?

VLSM allows using different subnet mask lengths within the same network, enabling more efficient IP address allocation by creating subnets of various sizes based on requirements.

Common Use Cases

  • Network planning and design
  • IP address allocation schemes
  • Router and switch configuration
  • VLSM implementation
  • Network troubleshooting
  • Security zone segmentation
  • DHCP scope planning
  • Documentation and inventory

Sponsored Content

AdSense Square Ad Placeholder

Technical Details

IPv4 Address Structure:

  • 32-bit Address: Divided into network and host portions
  • Dotted Decimal: Four octets separated by periods
  • Subnet Mask: Binary pattern defining network/host boundary
  • CIDR Prefix: Number of network bits (/8 to /30 for subnets)
  • Host Calculation: 2^(32 - prefix length) - 2 usable addresses

Common Subnet Reference

CIDR Subnet Mask Hosts Subnets
/8255.0.0.016,777,214256
/16255.255.0.065,53465,536
/24255.255.255.025416,777,216
/25255.255.255.12812633,554,432
/26255.255.255.1926267,108,864
/27255.255.255.22430134,217,728
/28255.255.255.24014268,435,456
/30255.255.255.25221,073,741,824

Programming Examples

Python:

import ipaddress

def calculate_subnet(ip_with_prefix):
    network = ipaddress.IPv4Network(ip_with_prefix, strict=False)
    
    return {
        'network_address': str(network.network_address),
        'broadcast_address': str(network.broadcast_address),
        'subnet_mask': str(network.netmask),
        'prefix_length': network.prefixlen,
        'num_hosts': network.num_addresses - 2,
        'host_range': f"{network.network_address + 1} - {network.broadcast_address - 1}"
    }

# Example usage
result = calculate_subnet("192.168.1.100/24")
print(f"Network: {result['network_address']}")
print(f"Broadcast: {result['broadcast_address']}")
print(f"Hosts: {result['num_hosts']}")
            

JavaScript:

function calculateSubnet(ip, prefixLength) {
    const ipNum = ipToNumber(ip);
    const mask = (0xFFFFFFFF << (32 - prefixLength)) >>> 0;
    
    const networkAddr = ipNum & mask;
    const broadcastAddr = networkAddr | (0xFFFFFFFF >>> prefixLength);
    const numHosts = Math.pow(2, 32 - prefixLength) - 2;
    
    return {
        networkAddress: numberToIp(networkAddr),
        broadcastAddress: numberToIp(broadcastAddr),
        subnetMask: numberToIp(mask),
        numHosts: numHosts,
        firstHost: numberToIp(networkAddr + 1),
        lastHost: numberToIp(broadcastAddr - 1)
    };
}

function ipToNumber(ip) {
    return ip.split('.').reduce((acc, octet) => (acc << 8) + parseInt(octet), 0) >>> 0;
}

function numberToIp(num) {
    return [(num >>> 24) & 255, (num >>> 16) & 255, (num >>> 8) & 255, num & 255].join('.');
}
            

Advertisement

AdSense Bottom Ad Placeholder