CIDR Subnet Calculator
Calculate network address, broadcast, host range, and subnet mask from CIDR notation.
About this tool
A CIDR Subnet Calculator is an essential tool for network administrators and engineers who need to understand how IP addresses and subnets work. CIDR (Classless Inter-Domain Routing) notation provides a compact way to represent IP address ranges and their associated netmasks, making network planning and management significantly simpler. This tool calculates the network address, broadcast address, usable host range, and subnet mask from a given CIDR notation, helping you quickly determine critical network parameters without manual calculation.
To use the calculator, simply enter an IP address followed by a forward slash and the number of network bits (for example, 192.168.0.0/24). The tool instantly displays the network address, broadcast address, first and last usable host addresses, and the subnet mask in dotted decimal notation. This is invaluable when designing network segments, assigning IP ranges to departments or services, or troubleshooting connectivity issues. Network professionals often need these calculations during infrastructure planning, cloud deployment, or when auditing existing network configurations.
Understanding CIDR notation is fundamental to modern networking, especially in cloud environments like AWS, Azure, and Google Cloud where subnetting controls resource access and segmentation. The tool works with both IPv4 addresses and helps demystify the relationship between the prefix length and the number of available hosts. Whether you're a network engineer designing enterprise infrastructure, a system administrator managing servers, or a student learning networking concepts, this calculator eliminates calculation errors and saves time during critical planning phases.
Frequently Asked Questions
Code Implementation
import ipaddress
def cidr_info(cidr: str) -> dict:
network = ipaddress.ip_network(cidr, strict=False)
return {
"network_address": str(network.network_address),
"broadcast_address": str(network.broadcast_address),
"subnet_mask": str(network.netmask),
"prefix_length": network.prefixlen,
"total_addresses": network.num_addresses,
"usable_hosts": max(0, network.num_addresses - 2),
"first_host": str(network.network_address + 1),
"last_host": str(network.broadcast_address - 1),
}
# Example
info = cidr_info("192.168.1.0/24")
for k, v in info.items():
print(f"{k}: {v}")
# Check if IP is in network
net = ipaddress.ip_network("10.0.0.0/8", strict=False)
ip = ipaddress.ip_address("10.5.20.1")
print(f"10.5.20.1 in 10.0.0.0/8: {ip in net}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.