User Rating 0.0
Total Usage 0 times
IPv4 or IPv6 supported
Is this tool helpful?

Your feedback helps us improve.

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.

cidr ip calculator subnet mask network tools ipv6

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.

BlockSize = minTrailingZeros(IPstart)floor(log2(IPend IPstart + 1))

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):

P = Width k

We then output the CIDR block IPstart/P and advance the start pointer:

IPnext = IPstart + 2k

Reference Data

CIDR PrefixSubnet MaskTotal IPsWildcard Mask
/32255.255.255.25510.0.0.0
/31255.255.255.25420.0.0.1
/30255.255.255.25240.0.0.3
/29255.255.255.24880.0.0.7
/28255.255.255.240160.0.0.15
/27255.255.255.224320.0.0.31
/26255.255.255.192640.0.0.63
/24255.255.255.02560.0.0.255
/16255.255.0.065,5360.0.255.255
/8255.0.0.016,777,2160.255.255.255

Frequently Asked Questions

CIDR blocks rely on binary powers of two. If your range size isn't exactly a power of two (like 2, 4, 8, 256), or if the starting IP doesn't align with the block size binary boundary, the range must be split into smaller chunks to cover the specific area without including outside addresses.
Yes. This tool uses BigInt precision to fully support 128-bit IPv6 address spaces, including compressed notation (e.g., ::1).
The logic requires IP_start <= IP_end. The tool will automatically detect this error and ask you to swap the values.
Technically no, but extremely fragmented ranges (billions of non-contiguous blocks) might take longer to compute. In practical network scenarios, the algorithm is instant.
AWS Security Groups accept individual CIDR rules. If you need to whitelist a range like 10.0.0.5-10.0.0.12, copy the resulting list from this tool and add a separate inbound rule for each CIDR line generated.