CIDR difference operates on the principle of set subtraction, where addresses present in set B are removed from set A, and the result is expressed as the minimal set of non-overlapping CIDR blocks.
Basic Example (Minimal Mode):
- Set A: 192.168.1.0/24 (256 addresses: .0 to .255)
- Set B: 192.168.1.0/25 (128 addresses: .0 to .127)
- Result: 192.168.1.128/25 (128 remaining addresses: .128 to .255)
Complex Example:
- Set A: 10.0.0.0/22 (1024 addresses: 10.0.0.0 to 10.0.3.255)
- Set B: 10.0.1.0/24 (256 addresses: 10.0.1.0 to 10.0.1.255)
- Result: 10.0.0.0/24, 10.0.2.0/23 (remaining 768 addresses)
Constrained Alignment Mode:
When you enable alignment constraints with a specific prefix (e.g., /24), the tool ensures all resulting CIDR blocks align on those boundaries. This is useful for maintaining clean subnet organization:
- Without constraint: May produce /25, /26, /27 subnets for minimal representation
- With /24 constraint: Forces all results to /24 boundaries, even if less optimal
Algorithm Behavior:
- Expands all CIDR blocks to their individual IP ranges
- Performs set subtraction (removes B addresses from A)
- Aggregates remaining addresses into minimal CIDR representation
- Applies alignment constraints if specified
- Separates results by IPv4 and IPv6
Edge Cases:
- If B completely contains A, the result is empty
- If A and B don't overlap, the result equals A
- Multiple blocks in A and B are processed together as unified sets