TTR Networks

What is bgpq4?

BGP filter generator

bgpq4 is a free command-line tool that turns IRR data, such as an AS-SET, into ready-to-paste BGP prefix-lists or AS-path filters for your router.

Writing customer and peer filters by hand does not scale: a transit customer's AS-SET can expand to dozens of ASNs and thousands of prefixes, and it changes whenever their own customers change. bgpq4 automates the lookup. Given an ASN or a set name, it queries an IRR server (whois.radb.net unless told otherwise), expands the set recursively into member ASNs, collects the route or route6 objects each of those ASNs originates, and prints the result in the syntax of your platform. A few options cover most daily use: -l names the generated list, -6 asks for IPv6 prefixes instead of IPv4, -A aggregates adjacent prefixes into a shorter list, -h picks a different IRR server and -S restricts which IRR sources are trusted. Output formats include Cisco-style prefix-lists by default and others such as Juniper (-J) and BIRD (-b). It is the maintained successor to bgpq3, which you will still see referenced in older guides and scripts.

In practice bgpq4 runs on a schedule, often from automation that pushes the result to routers. The tool is only as good as the data behind it: IRR objects are often stale, and some registries accept objects with little checking, so filters can include prefixes the customer no longer uses or miss new ones they forgot to register. A sensible pipeline sanity-checks the output before deploying it, because an empty list is effectively a deny-all, and a sudden huge growth may mean someone added a large set by mistake. Combine IRR filters with ROV and max-prefix limits rather than relying on one layer. The IRR, RPSL and AS-SETs lesson walks through set expansion and generating filters with bgpq4.

Lessons that use bgpq4

  • IRR, RPSL and AS-SETsTeaches this term · Intermediate · 60 min

    How networks publish what they announce and how their neighbours turn it into filters: Internet Routing Registries, whois queries, RPSL objects and attributes, AS-SET expansion, bgpq4, and the pitfalls of unsigned routing data.

  • BGP FundamentalsIntermediate · 75 min

    How the Border Gateway Protocol glues the internet together: autonomous systems, sessions, path attributes, best-path selection, iBGP scaling and a hands-on eBGP lab with real FRR configuration.

Related terms