IPv4 prefix set intersect
ipv4-prefix-set-intersect · version 1.0.0 · URLs & IP addresses · free, no key needed
Intersect two IPv4 prefix sets into one sorted minimal list of disjoint CIDRs.
Use when you need to: intersection of two ipv4 prefix sets · cidr blocks common to two ipv4 sets · addresses covered by both prefix sets.
Decide before calling
Read the versioned contract and the supported scope below. Reuse ipv4-prefix-set-intersect@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-intersect@1.0.0 for intersection 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
- intersection of two ipv4 prefix sets
- cidr blocks common to two ipv4 sets
- addresses covered by both prefix sets
- overlap of two ipv4 prefix lists as cidrs
- shared coverage of ipv4 prefix sets
- prefix set meet operation
- keep only overlapping ipv4 prefixes
Not supported
- IPv6 prefix sets
- a yes or no overlap flag for exactly two prefixes
- non-contiguous wildcard bit masks
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 intersection.
- prefixes is the shortest list of non-overlapping CIDRs, sorted by network address, whose addresses are exactly the intersection. The list is empty when the sets are disjoint. 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. Intersecting with an empty set yields an empty cover.
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/8"
],
"right": [
"10.2.0.0/16",
"11.0.0.0/8"
]
}
Response:
{
"result": {
"prefixes": [
"10.2.0.0/16"
],
"count": 1
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "ipv4-prefix-set-intersect",
"version": "1.0.0",
"input": {
"left": [
"10.0.0.0/8"
],
"right": [
"10.2.0.0/16",
"11.0.0.0/8"
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/ipv4-prefix-set-intersect/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"left":["10.0.0.0/8"],"right":["10.2.0.0/16","11.0.0.0/8"]}'
The machine-readable contract is at /v1/tools/ipv4-prefix-set-intersect/versions/1.0.0.
CLI
node cli.mjs run ipv4-prefix-set-intersect 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 union: Union 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 range to cidrs: Convert an arbitrary IPv4 address range into the minimal list of CIDR blocks that exactly covers it.
- IPv4 CIDR overlap: Test whether two IPv4 CIDR blocks overlap (share at least one address).
- IPv4 CIDR parse: Parse an IPv4 CIDR block into its network, broadcast, netmask, wildcard mask, usable host range and address counts.