Skip to content
πŸ› οΈToolsShed

IP Subnet Calculator

Calculate subnet mask, network address, broadcast, and host range for any CIDR block.

About this tool

The IP Subnet Calculator works out the subnet mask, network address, broadcast address, and usable host range for any IPv4 CIDR block. It removes the need to do binary math by hand just to find where a subnet starts and ends.

Enter an IP address and a CIDR prefix like 192.168.1.0/24, and the tool reports the subnet mask, network address, broadcast address, host range, and total host count. It is handy for network administrators, students learning subnetting, and developers planning out address space.

Remember that the prefix length determines how many hosts fit inside the block: a smaller prefix leaves more host bits and more addresses. Everything runs locally in your browser, so no IP details are sent anywhere.

Frequently Asked Questions

Code Implementation

import ipaddress

# Parse a network in CIDR notation
network = ipaddress.ip_network('192.168.1.0/24', strict=False)

print(f"Network address : {network.network_address}")   # 192.168.1.0
print(f"Broadcast addr  : {network.broadcast_address}") # 192.168.1.255
print(f"Subnet mask     : {network.netmask}")           # 255.255.255.0
print(f"Prefix length   : /{network.prefixlen}")        # /24
print(f"Total addresses : {network.num_addresses}")     # 256
print(f"Usable hosts    : {network.num_addresses - 2}") # 254

# Iterate over host addresses (excludes network and broadcast)
for host in list(network.hosts())[:3]:
    print(host)  # 192.168.1.1, .2, .3 ...

# Check if an IP is in the subnet
ip = ipaddress.ip_address('192.168.1.42')
print(ip in network)  # True

# Split into subnets
for subnet in network.subnets(prefixlen_diff=1):  # two /25 subnets
    print(subnet)

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.