Skip to content

A command-line tool for aggregating IPv4 prefixes

Notifications You must be signed in to change notification settings

ugwis/prefix-aggregator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prefix-aggregator

A command-line tool for aggregating IPv4 prefixes

How to use

Aggregate to the largest prefix possible

$ prefix-aggregator << EOS
10.0.0.0/24
10.0.1.0/24
10.0.2.0/24
EOS

Expected to

10.0.0.0/23
10.0.2.0/24

The bigger, the better.

$ prefix-aggregator << EOS
10.0.0.0/8
10.0.0.0/16
10.0.1.0/16
EOS

Expected to

10.0.0.0/8

Focus only on your goal

$ curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | sort -V | uniq | wc -l
4314
$ curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | sort -V | uniq | prefix-aggregator | wc -l
1101