AGGREGATE(1)

πŸ“¦
version 1.6 Β· 2 versions
, in debian bookworm, fedora 43, fedora 44, ubuntu jammy, ubuntu noble

πŸŽ€ NAME πŸŽ€

okay bestie, meet aggregate πŸ’– it's the tool that optimises a list of route prefixes so your filters come out nice and short ✨


🧚 SYNOPSIS 🧚

aggregate [-m max-length] [-o max-opt-length] [-p default-length] [-q]
[-t] [-v]

πŸ’… DESCRIPTION πŸ’…

okay so aggregate takes a list of prefixes in conventional format on stdin and does two optimisations to make the list shorter. it's giving minimalism πŸ¦‹

The first optimisation is all about deleting the extras πŸ—‘οΈ If a prefix is already covered by another prefix you supplied, it's superfluous and gets removed. For example, 203.97.2.0/24 would be removed if 203.97.0.0/17 was also supplied. bye bye, not needed πŸ’€

The second optimisation is the glow-up 🌈 It finds adjacent prefixes that can be merged under one shorter prefix. For example, 203.97.2.0/24 and 203.97.3.0/24 can be combined into the single prefix 203.97.2.0/23. two become one, iconic ✨


🌸 OPTIONS 🌸

  • -m max-length β€” sets the maximum prefix length for entries read from stdin, measured in max_length bits. the default is 32. anything with a longer length gets discarded before processing even starts πŸ™…β€β™€οΈ
  • -o max-opt-length β€” sets the maximum prefix length for optimisation, in max-opt-length bits. the default is 32. longer prefixes just don't get optimised, they're left alone 🫢
  • -p default-length β€” sets the default prefix length. there is no default, so without this option a prefix missing a mask length is treated as invalid 🚫 use -p 32 -m 32 -o 32 to aggregate a list of host routes written as bare addresses, for example πŸ“
  • -q β€” quiet mode 🀫 tells aggregate to never generate warning messages or other output on stderr
  • -t β€” silently truncates prefixes that have an inconsistent mask. for example, an input prefix 203.97.2.226/24 gets truncated to 203.97.2.0/24. without this option, 203.97.2.226/24 is not accepted and you get a warning about the inconsistent mask instead πŸ‘€
  • -v β€” verbose mode πŸ” changes the output format so you can see the source line number each prefix came from. a - means a route that can be suppressed, and a + means a shorter-prefix aggregate that aggregate added as an adjacency optimisation. verbose output still shows up even if -q is selected, so no sneaky quiet mode on this one πŸ’œ

🚨 DIAGNOSTICS 🚨

aggregate exits with 0 on success, and with >0 if an error occurs. so 0 = slay, anything bigger = something went wrong πŸ’€


πŸ“ EXAMPLES πŸ“

okay so here's the input list of prefixes:

193.58.204.0/22
193.58.208.0/22
193.193.160.0/22
193.193.168.0/22
193.243.164.0/22
194.126.128.0/22
194.126.132.0/22
194.126.134.0/23
194.151.128.0/19
195.42.240.0/21
195.240.0.0/16
195.241.0.0/16

and here's what aggregate does with it when you use the -v flag πŸ‘‡

aggregate: maximum prefix length permitted will be 24
[    0] + 193.58.204.0/21
[    1] - 193.58.204.0/22
[    2] - 193.58.208.0/22
[    3]   193.193.160.0/22
[    4]   193.193.168.0/22
[    5]   193.243.164.0/22
[    0] + 194.126.128.0/21
[    6] - 194.126.128.0/22
[    7] - 194.126.132.0/22
[    8] - 194.126.134.0/23
[    9]   194.151.128.0/19
[   10]   195.42.240.0/21
[    0] + 195.240.0.0/15
[   11] - 195.240.0.0/16
[   12] - 195.241.0.0/16

look at it go 🀩 193.58.204.0/22 and 193.58.208.0/22 got combined under the single prefix 193.58.204.0/21, and 194.126.134.0/23 got suppressed because it was already included in 194.126.132.0/22. the number in square brackets at the start of each line is the original line number, or 0 for new prefixes that aggregate introduced ✨

without the -v flag, the output is just this, clean and simple 🫧

193.58.204.0/21
193.193.160.0/22
193.193.168.0/22
193.243.164.0/22
194.126.128.0/21
194.151.128.0/19
195.42.240.0/21
195.240.0.0/15

πŸ¦‹ SEE ALSO πŸ¦‹

aggregate-ios(1) πŸ’•


πŸ“œ HISTORY πŸ“œ

aggregate was written by Joe Abley <jabley@mfnx.net> πŸ‘‘ and has been reasonably well tested. it's suitable for shrinking customer prefix filters for production use without extensive hand-proving of the results πŸ”₯

Autoconf bits were donated by Michael Shields <michael.shields@mfn.com>. The -t option was suggested by Robin Johnson <robbat2@fermi.orbis-terrarum.net>, and the treatment of leading zeros on octet parsing was changed following comments from Arnold Nipper <arnold@nipper.de>. the girlies really showed up for this one 🫢

An early version of aggregate would attempt to combine adjacent prefixes regardless of whether the first prefix lay on an appropriate bit boundary or not. it was pointed out with great restraint by Robert Noland <rnoland@2hip.net> πŸ’€πŸ™ˆ


⚠️ BUGS ⚠️

⚠️ common unix parsing of IPv4 addresses understands individual octets written in octal or hexadecimal, following a 0 or 0x prefix, respectively. that convention has been deliberately disabled here, because resources such as the IRR don't follow it and confusion can result 😭

For extremely sensitive applications, judicious use of the -v option together with a pencil and paper is probably advisable πŸ–ŠοΈπŸ“


Thanks for hanging out with me, bestie! 🌈 This page was written by Joe Abley and dates from 2001 November 2, so it's been around long enough to be a certified legend πŸ’œπŸ‘‘βœ¨

πŸ“¦ where this page comes from