IP range calculator

The IP range calculator converts an IPv4 address range to the shortest list of CIDR blocks, merges and summarizes a list of addresses, blocks, and ranges, and checks whether an address is in the merged list.

The calculations run in the browser. Please enable JavaScript.

Address range to CIDR list
Enter the first and last IPv4 addresses, such as 192.168.1.10 and 192.168.1.100. The result is the smallest number of blocks that exactly cover the range, including both addresses.
Merge and summarize an address list
One or more entries per line, separated by spaces, commas, or semicolons: an address (10.0.0.1), a CIDR block (10.0.0.0/24 or 10.0.0.0/255.255.255.0), or a range (10.0.0.1-10.0.0.50). Text after the # character is ignored. Up to 10,000 lines.
These addresses are removed from the result. Use the same format as in the list.
Check whether an address is in the list
One IPv4 address per line, up to 10,000 lines. The check runs against the merged result, after the exclusions.

    Everything runs in your browser; nothing is sent or stored.

    • Under "Output format", choose "CIDR only" or nginx, Apache, or iptables lines. The format applies to both block lists.
    • Only IPv4 addresses are supported. The nginx, Apache, and iptables lines are sample text: before you use them, check their order against the other rules in the configuration file or firewall.
    • Under "Address range to CIDR list", enter a "Start address" and an "End address", and the blocks that cover the range appear in the "Block list" field.
    • In the "Addresses, blocks, and ranges" field, enter one or more entries per line, and in the "Addresses to exclude (optional)" field, enter the addresses to remove from the result.
    • In the "Addresses to check" field, enter one address per line, and next to each address the tool shows whether it is in the merged list and in which block.
    • Copy a block list by clicking "Copy" below the "Block list" field.

    CIDR notation and splitting a range into blocks

    In CIDR (Classless Inter-Domain Routing) notation, a block of addresses is written as the network address, a slash, and the prefix length, such as 10.0.0.0/24. The prefix states how many bits at the start of the address are fixed, so a /24 block contains 256 addresses and a /16 block contains 65,536 addresses. The size of a block is always a power of 2, and the block starts at an address whose numeric value is divisible by the block size. A range that fails either condition is split into several blocks: for example, the range 192.168.1.10 to 192.168.1.100 contains 91 addresses and is covered by seven blocks, in sizes from /32 to /27.

    Merging and summarizing an address list

    Allowlists grow over time and collect overlapping blocks, single addresses that are already part of another block, and adjacent blocks. The tool sorts the entries, merges overlapping and adjacent entries, removes the addresses in the exclusion field, and returns the smallest number of blocks that exactly cover the remaining addresses. Two adjacent blocks merge into one block only when together they form a valid block: 10.0.0.0/25 and 10.0.0.128/25 merge into 10.0.0.0/24, while 10.0.1.0/24 and 10.0.2.0/24 stay as two blocks, because a /23 block cannot start at the address 10.0.1.0. A shorter list is easier to read and review, and it needs fewer lines in the configuration file or fewer rules in the firewall.

    Lines for nginx, Apache, and iptables

    In nginx format, each block becomes the line allow 10.0.0.0/24;, in Apache format the line Require ip 10.0.0.0/24, and in iptables format the rule iptables -A INPUT -s 10.0.0.0/24 -j ACCEPT. The lines that the tool creates only allow access, so to limit access to the addresses in the list, you also need a line that blocks all other addresses, such as deny all; after the allow lines in nginx. In the iptables command, the -A option appends the rule to the end of the chain, so a blocking rule that appears earlier in the chain applies first. Before you use the lines, check their order against the other rules, and make sure that the address you connect from is in the list, so you do not lose access to the server.

    Sample entries for the "Addresses, blocks, and ranges" field

    • 10.0.0.1a single address, read as a /32 block.
    • 10.0.0.0/24a block with a prefix length.
    • 10.0.0.0/255.255.255.0the same block, with a netmask instead of the prefix length.
    • 10.0.0.1-10.0.0.50a range of 50 addresses, covered by eight blocks in the result.
    • 0.0.0.0/0a block that contains every IPv4 address.
    • 10.0.0.1 # officethe text after the # character is a comment, and the tool ignores it.
    Did you know?

    With our firewall and VPN service, you can add firewall rules for a VPS or a dedicated server on our external firewall, to open and block ports and IP addresses, even after the server is already up and running.

    Firewall and VPN

    IP range calculator FAQ

    Does the tool support IPv6 addresses?

    No. The IP range calculator supports IPv4 addresses only, and an IPv6 address in the list shows an error message with the line number. To calculate the network range of an IPv6 prefix, you can use the "IPv6 calculator" tool.

    Can I exclude a single address from a block?

    Yes. An address in the "Addresses to exclude (optional)" field is removed from the result even when it is inside a larger block in the list, and the block is split into several smaller blocks. For example, excluding 10.0.0.1 from 10.0.0.0/24 returns eight blocks that hold 255 addresses.

    Why is a value with a leading zero, such as 010, rejected?

    The tool rejects values with leading zeros, because some systems read a number that starts with a zero as an octal number, so 010 can be read as 8 rather than 10. Rejecting these values prevents a rule that applies to a different address from the one you meant. Enter the number without the zero, such as 10 instead of 010.

    Why does a message say that the block was calculated from the network address?

    The message appears when the address before the slash is not the network address, which is the first address in the block. In that case, such as with the block 10.0.0.5/24, the tool calculates the block from its network address, 10.0.0.0/24, and the message states the number of blocks calculated this way. Some systems reject a block whose address is not the network address, so it is a good idea to also correct the entry in your original list.

    Does an excluded address show as part of the list in the check?

    No. An excluded address shows in the check as an address that is not in the list, because the check runs against the merged result, after the exclusions. For example, with the values that appear in the tool when the page loads, the address 192.168.100.7 is inside the block 192.168.0.0/16 but shows as not in the list, because the block 192.168.100.0/24 is excluded.

    Is there a limit on the size of the list?

    Yes. Each of the three list fields accepts up to 10,000 lines and up to 512 KB, and the address list and the exclusion list also accept up to 10,000 entries each. The merged result can include up to 10,000 CIDR blocks.

    Shopping cart

    Your cart is emptyYou can start with one of our popular plans.

    Site search

    Accessibility

    Text size
    100%
    Accessibility statement