IP Range to CIDR Converter
Convert IP address ranges to CIDR blocks instantly. Supports IPv4 and IPv6. Optimized for network engineers, AWS security groups, and firewall rules.
Generated CIDR Blocks
These blocks cover exactly the range from Start IP to End IP, inclusive.
About
Network configuration often requires defining strict address blocks, yet specific requirements often come in the form of arbitrary ranges (e.g., 192.168.1.10 to 192.168.1.50). Firewalls, routers, and cloud security groups (like AWS or Azure) typically reject raw ranges, demanding standard CIDR (Classless Inter-Domain Routing) notation instead. Failing to convert these ranges correctly can leave gaps in security coverage or accidentally expose unintended addresses.
This tool eliminates that risk by mathematically decomposing any start-to-end IP range into the smallest possible set of valid CIDR blocks. It handles both IPv4 (32-bit) and IPv6 (128-bit) addresses, utilizing arbitrary-precision arithmetic to ensure bit-perfect accuracy. Whether you are migrating subnets or whitelisting specific IPs, this calculator ensures your network masks align perfectly with the binary boundaries of the Internet Protocol standards.
Formulas
The core challenge is finding the largest possible power of two, 2k, that satisfies two conditions: it must divide the current starting IP (binary alignment), and the resulting block must fit within the remaining range.
Once the optimal exponent k is found, the CIDR prefix length P is calculated based on the address bit-width (32 for IPv4, 128 for IPv6):
We then output the CIDR block IPstart/P and advance the start pointer:
Reference Data
| CIDR Prefix | Subnet Mask | Total IPs | Wildcard Mask |
|---|---|---|---|
| /32 | 255.255.255.255 | 1 | 0.0.0.0 |
| /31 | 255.255.255.254 | 2 | 0.0.0.1 |
| /30 | 255.255.255.252 | 4 | 0.0.0.3 |
| /29 | 255.255.255.248 | 8 | 0.0.0.7 |
| /28 | 255.255.255.240 | 16 | 0.0.0.15 |
| /27 | 255.255.255.224 | 32 | 0.0.0.31 |
| /26 | 255.255.255.192 | 64 | 0.0.0.63 |
| /24 | 255.255.255.0 | 256 | 0.0.0.255 |
| /16 | 255.255.0.0 | 65,536 | 0.0.255.255 |
| /8 | 255.0.0.0 | 16,777,216 | 0.255.255.255 |