On 2012-06-12, at 04:14, Jamie Baddeley wrote:
ISTR a tool that some dodgy geezer called jabley wrote
years ago called "aggregate" or "aggregate-ios" that might help.
Rumour has it he lurks on this list so he might be able to expound it's virtues.
I dare say Joe might insist using things like awk or sed to help with parsing the input
file or something.
aggregate-ios was in fact once an awk script. But then Michael Shields at AboveNet
re-wrote it in perl. aggregate is written in C, though, which you'd think would make
it fast and efficient. You'd think.
aggregate - optimise a list of route prefixes to help make nice short
aggregate [-m max-length] [-o max-opt-length] [-p default-length] [-q]
Takes a list of prefixes in conventional format on stdin, and performs
two optimisations to attempt to reduce the length of the prefix list.
The first optimisation is to remove any supplied prefixes which are
superfluous because they are already included in another supplied pre-
fix. For example, 18.104.22.168/24 would be removed if 22.214.171.124/17 was
The second optimisation identifies adjacent prefixes that can be com-
bined under a single, shorter-length prefix. For example, 126.96.36.199/24
and 188.8.131.52/24 can be combined into the single prefix 184.108.40.206/23.
Sets the maximum prefix length for entries read from stdin
max_length bits. The default is 32. Prefixes with longer lengths
will be discarded prior to processing.
Sets the maximum prefix length for optimisation to max-opt-
length bits. The default is 32. Prefixes with longer lengths
will not be subject to optimisation.
Sets the default prefix length. There is no default; without
this option a prefix without a mask length is treated as
invalid. Use -p 32 -m 32 -o 32 to aggregate a list of host
routes specified as bare addresses, for example.
-q Sets quiet mode -- instructs aggregate never to generate warning
messages or other output on stderr.
-t Silently truncate prefixes that seem to have an inconsistent
prefix: e.g. an input prefix 220.127.116.11/24 would be truncated
to 18.104.22.168/24. Without this option an input prefix
22.214.171.124/24 would not be accepted, and a warning about the
inconsistent mask would be generated.
-v Sets verbose mode. This changes the output format to display the
source line number that the prefix was obtained from, together
with a preceding "-" to indicate a route that can be suppressed,
or a "+" to indicate a shorter-prefix aggregate that was added
by aggregate as an adjacency optimisation. Note that verbose
output continues even if -q is selected.
Aggregate exits 0 on success, and >0 if an error occurs.
The following list of prefixes:
is optimised as followed by aggregate (output shown using the -v flag):
aggregate: maximum prefix length permitted will be 24
[ 0] + 126.96.36.199/21
[ 1] - 188.8.131.52/22
[ 2] - 184.108.40.206/22
[ 3] 220.127.116.11/22
[ 4] 18.104.22.168/22
[ 5] 22.214.171.124/22
[ 0] + 126.96.36.199/21
[ 6] - 188.8.131.52/22
[ 7] - 184.108.40.206/22
[ 8] - 220.127.116.11/23
[ 9] 18.104.22.168/19
[ 10] 22.214.171.124/21
[ 0] + 126.96.36.199/15
[ 11] - 188.8.131.52/16
[ 12] - 184.108.40.206/16
Note that 220.127.116.11/22 and 18.104.22.168/22 were combined under the
single prefix 22.214.171.124/21, and 126.96.36.199/23 was suppressed
because it was included in 188.8.131.52/22. The number in square
brackets at the beginning of each line indicates the original line num-
ber, or zero for new prefixes that were introduced by aggregate.
The output without the -v flag is as follows:
Aggregate was written by Joe Abley <jabley(a)mfnx.net>et>, and has been rea-
sonably well tested. It is suitable for reducing customer prefix fil-
ters for production use without extensive hand-proving of results.
Autoconf bits were donated by Michael Shields
<michael.shields(a)mfn.com>om>. The -t option was suggested by Robin John-
son <robbat2(a)fermi.orbis-terrarum.net>et>, and the treatment of leading
zeros on octet parsing was changed following comments from Arnold Nip-
An early version of aggregate would attempt to combine adjacent pre-
fixes regardless of whether the first prefix lay on an appropriate bit
boundary or not (pointed out with great restraint by Robert Noland
Common unix parsing of IPv4 addresses understands the representation of
individual octets in octal or hexadecimal, following a "0" or
fix, respectively. That convention has been deliberately disabled here,
since resources such as the IRR do not follow the convention, and con-
fusion can result.
For extremely sensitive applications, judicious use of the -v option
together with a pencil and paper is probably advisable.
Joe Abley 2001 November 2 AGGREGATE(1)