Skip to content

Commit c791394

Browse files
committed
Improve README with better structure, installation instructions, and macOS security guidance
1 parent cdc52b0 commit c791394

File tree

1 file changed

+109
-18
lines changed

1 file changed

+109
-18
lines changed

README.md

Lines changed: 109 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,129 @@
1-
# prefix-aggregator
2-
A command-line tool for aggregating IPv4 prefixes
1+
# Prefix Aggregator
32

4-
# How to use
5-
## Aggregate to the largest prefix possible
3+
A command-line tool for efficiently aggregating IPv4 prefixes into the smallest possible set of CIDR blocks.
4+
5+
## Features
6+
7+
- Aggregates adjacent and overlapping IPv4 CIDR blocks
8+
- Optimizes for the smallest number of resulting prefixes
9+
- Works with standard input/output for easy integration with other tools
10+
- Cross-platform support (Linux, macOS, Windows)
11+
12+
## Installation
13+
14+
### Download Binary
15+
16+
Pre-built binaries are available for various platforms on the [Releases page](https://github.com/ugwis/prefix-aggregator/releases).
17+
18+
1. Download the appropriate binary for your platform:
19+
- Linux: `prefix-aggregator-x86_64-unknown-linux-gnu.zip`
20+
- Windows: `prefix-aggregator-x86_64-pc-windows-gnu.zip`
21+
- macOS (Intel): `prefix-aggregator-x86_64-apple-darwin.zip`
22+
- macOS (Apple Silicon): `prefix-aggregator-aarch64-apple-darwin.zip`
23+
24+
2. Extract the ZIP file and place the binary in a directory included in your PATH.
25+
26+
### macOS Security Warning
27+
28+
When running the application on macOS, you might see a security warning: "Apple could not verify this app is free from malware."
29+
30+
To resolve this:
31+
32+
1. Right-click (or Control-click) on the `prefix-aggregator` binary
33+
2. Select "Open" from the context menu
34+
3. Click "Open" in the dialog that appears
35+
4. The app will now be saved as an exception to your security settings
36+
37+
### Building from Source
38+
39+
If you have Rust installed, you can build from source:
40+
41+
```bash
42+
git clone https://github.com/ugwis/prefix-aggregator.git
43+
cd prefix-aggregator
44+
cargo build --release
45+
```
46+
47+
The binary will be available at `target/release/prefix-aggregator`.
48+
49+
## Usage
50+
51+
### Basic Usage
52+
53+
Provide a list of IP prefixes via standard input:
54+
55+
```bash
56+
prefix-aggregator < list_of_prefixes.txt
57+
```
58+
59+
Or use a here document:
60+
61+
```bash
62+
prefix-aggregator << EOF
63+
192.168.1.0/24
64+
192.168.2.0/24
65+
192.168.3.0/24
66+
EOF
67+
```
68+
69+
### Examples
70+
71+
#### Example 1: Aggregate Adjacent Prefixes
72+
73+
Input:
674
```
7-
$ prefix-aggregator << EOS
875
10.0.0.0/24
976
10.0.1.0/24
1077
10.0.2.0/24
11-
EOS
1278
```
13-
Expected to
79+
80+
Output:
1481
```
1582
10.0.0.0/23
1683
10.0.2.0/24
1784
```
18-
19-
## The bigger, the better.
85+
86+
The tool automatically combines `10.0.0.0/24` and `10.0.1.0/24` into `10.0.0.0/23`.
87+
88+
#### Example 2: Handle Overlapping Prefixes
89+
90+
Input:
2091
```
21-
$ prefix-aggregator << EOS
2292
10.0.0.0/8
2393
10.0.0.0/16
2494
10.0.1.0/16
25-
EOS
2695
```
27-
Expected to
96+
97+
Output:
2898
```
2999
10.0.0.0/8
30100
```
31101

32-
## Focus only on your goal
33-
```
34-
$ curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | sort -V | uniq | wc -l
35-
4314
36-
$ curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | sort -V | uniq | prefix-aggregator | wc -l
37-
1101
102+
The tool recognizes that `10.0.0.0/8` already includes the other prefixes.
103+
104+
#### Example 3: Real-world Application
105+
106+
Aggregating AWS IP ranges:
107+
108+
```bash
109+
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | sort -V | uniq | wc -l
110+
# 4314 prefixes before aggregation
111+
112+
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | sort -V | uniq | prefix-aggregator | wc -l
113+
# 1101 prefixes after aggregation
38114
```
115+
116+
This example shows how the tool can reduce 4314 AWS IP prefixes to just 1101 prefixes.
117+
118+
## How It Works
119+
120+
The prefix-aggregator uses an algorithm that:
121+
122+
1. Sorts the input prefixes
123+
2. Identifies adjacent prefixes that can be combined
124+
3. Merges overlapping prefixes
125+
4. Recursively applies these operations until no further aggregation is possible
126+
127+
## License
128+
129+
[MIT License](LICENSE)

0 commit comments

Comments
 (0)