Dockerfile Generator
Generate a production Dockerfile with multi-stage builds and layer caching.
Convert a start and end address into the smallest set of CIDR blocks.
The IP Range to CIDR converter turns an arbitrary start and end address into the smallest set of CIDR blocks that covers it exactly — no gap, no overlap — which is what a firewall rule actually needs.
Firewalls, security groups and allowlists take CIDR blocks, and the range you actually need is almost never a single tidy one. Give a start and end address and this produces the smallest set of blocks covering exactly that range — no gap, no overlap.
A range only collapses to one block when it starts on a power-of-two boundary and has a power-of-two length. Anything else needs several, and the algorithm is greedy: at each step it takes the largest block that both begins at the current address and fits inside what is left. The total is shown against the range size so you can confirm the coverage is exact, which is the thing that matters when the output becomes a firewall rule.
Greedily taking the largest aligned block that fits is optimal for this problem, so no shorter list covers the same range.
Every block sits entirely inside the range, so the rule never allows an address you did not intend.
The total of the blocks is compared against the range size, so a mistake would be visible rather than silent.
Why a range needs several blocks — CIDR requires a power-of-two size starting on a power-of-two boundary.
As CIDR does; a range crossing from 10.x into 11.x is decomposed like any other.
The first address the range should include.
The last one, inclusive.
The smallest set that covers the range exactly.
The total is compared against the range size, so an error is visible.
Because CIDR blocks must start on a power-of-two boundary and have a power-of-two size. A range from .1 to .254 satisfies neither, so it decomposes into a series of aligned blocks.
Yes. Greedily taking the largest aligned block that fits is provably optimal for this problem, so no shorter list of CIDR blocks covers the same range.
No. Every block is chosen to fit entirely inside the range, so the coverage is exact — which is essential when the output becomes a firewall rule.
It works fine. CIDR ignores the old class system entirely; a range from 10.255.255.250 to 11.0.0.5 simply produces the blocks that cover it.
What people who use the IP Range to CIDR think of it. Reviews come from visitors and are posted as written.
No ratings yet
Yours would be the first.
0 reviews
Newest first
No reviews yet
Be the first to rate the IP Range to CIDR. It takes half a minute and no account.
Write the first reviewGenerate a production Dockerfile with multi-stage builds and layer caching.
Every HTTP status code, searchable, with what it actually means.
Serialise a JSON object into a percent-encoded URL query string.
Convert an INI or config file into structured JSON, sections and all.
Convert between px, rem, em, pt, %, vw and vh with the right context.
Normalise YAML indentation, quoting and key order in one pass.
Convert JSON to clean, correctly quoted YAML in one step.
Score a selector and find out which of two rules actually wins.