IPv4 prefix set union
ipv4-prefix-set-union · version 1.0.0 · URLs & IP addresses · free, no key needed
Union two IPv4 prefix sets into one sorted minimal list of disjoint CIDRs.
Use when you need to: union of two ipv4 prefix sets · merge two ipv4 prefix lists · combine ipv4 cidr sets into one cover.
Decide before calling
Read the versioned contract and the supported scope below. Reuse ipv4-prefix-set-union@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use ipv4-prefix-set-union@1.0.0 for union of two ipv4 prefix sets. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- union of two ipv4 prefix sets
- merge two ipv4 prefix lists
- combine ipv4 cidr sets into one cover
- shortest cidr cover of two prefix sets
- join overlapping ipv4 prefixes from two lists
- ipv4 network set union
- supernet the combined ipv4 prefix sets
Not supported
- IPv6 prefix sets
- keeping duplicate or overlapping entries in the output
- a single address range given as first and last host
Behavior
- left and right are arrays of canonical IPv4 CIDR strings (dotted decimal, a slash, and a prefix length 0-32 with no leading zeros). An omitted strict means true.
- When strict is true, any prefix with host bits set is invalid_input. When strict is false, those bits are cleared before the union.
- prefixes is the shortest list of non-overlapping CIDRs, sorted by network address, whose addresses are exactly the union. Aligned neighbors are merged. No prefix longer than /32 is emitted.
- More than 64 prefixes on one side, or a prefix longer than 18 code points, is limit_exceeded before syntax checks. A cover longer than 16 prefixes is limit_exceeded.
- Empty arrays are empty sets. The union may itself be empty.
Input
left(array of string, required): min items 0; max items 64; each min length 1; each max length 18; each pattern^(?:0|[1-9][0-9]{0,2})(?:\.(?:0|[1-9][0-9]{0,2})){3}/(?:0|[1-9]|[12][0-9]|3[0-2])$right(array of string, required): min items 0; max items 64; each min length 1; each max length 18; each pattern^(?:0|[1-9][0-9]{0,2})(?:\.(?:0|[1-9][0-9]{0,2})){3}/(?:0|[1-9]|[12][0-9]|3[0-2])$strict(boolean, optional)
Output
prefixes(array of string, required): min items 0; max items 16; each min length 1; each max length 18; each pattern^(?:0|[1-9][0-9]{0,2})(?:\.(?:0|[1-9][0-9]{0,2})){3}/(?:0|[1-9]|[12][0-9]|3[0-2])$count(integer, required): min 0; max 16
Limits
- max prefixes per side: 64
- max prefix chars: 18
- max emitted prefixes: 16
Example
Request input:
{
"left": [
"10.0.0.0/25"
],
"right": [
"10.0.0.128/25"
]
}
Response:
{
"result": {
"prefixes": [
"10.0.0.0/24"
],
"count": 1
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "ipv4-prefix-set-union",
"version": "1.0.0",
"input": {
"left": [
"10.0.0.0/25"
],
"right": [
"10.0.0.128/25"
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/ipv4-prefix-set-union/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"left":["10.0.0.0/25"],"right":["10.0.0.128/25"]}'
The machine-readable contract is at /v1/tools/ipv4-prefix-set-union/versions/1.0.0.
CLI
node cli.mjs run ipv4-prefix-set-union 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- IPv4 prefix set equal: Report whether two IPv4 prefix sets cover exactly the same addresses.
- IPv4 prefix set intersect: Intersect two IPv4 prefix sets into one sorted minimal list of disjoint CIDRs.
- IPv4 prefix set subtract: Subtract one IPv4 prefix set from another into sorted minimal disjoint CIDRs.
- IPv4 CIDR aggregate: Merge a list of IPv4 CIDR blocks into the minimal equivalent list of non-overlapping CIDR blocks.
- IPv4 in CIDR: Test whether a canonical IPv4 address lies in a CIDR prefix whose host bits are zero.
- IPv4 CIDR parse: Parse an IPv4 CIDR block into its network, broadcast, netmask, wildcard mask, usable host range and address counts.