LinuxCommandLibrary

bgpgrep

Filter and search BGP routing data in MRT format

TLDR

Filter BGP data for a specific prefix

$ bgpgrep -p [192.0.2.0/24] [path/to/bgp.dump]
copy
Search for routes from a specific AS
$ bgpgrep -a [AS64496] [path/to/bgp.dump]
copy
Filter by AS path pattern
$ bgpgrep -P "[64496 64497]" [path/to/bgp.dump]
copy
Extract routes with a specific origin AS
$ bgpgrep -o [AS64496] [path/to/bgp.dump]
copy
Read from stdin (MRT format)
$ cat [bgp.dump] | bgpgrep -p [10.0.0.0/8]
copy
Output in machine-readable format
$ bgpgrep -m -p [prefix] [bgp.dump]
copy
Filter with multiple conditions
$ bgpgrep -p [prefix] -a [AS_number] [bgp.dump]
copy

SYNOPSIS

bgpgrep [-p prefix] [-a asn] [-o asn] [-P pattern] [-m] [file ...]

DESCRIPTION

bgpgrep is a tool for filtering and searching BGP routing data stored in MRT (Multi-threaded Routing Toolkit) format. It processes BGP table dumps and update files from route collectors like RIPE RIS and RouteViews.
The tool supports filtering by IP prefix, AS number, AS path patterns, and origin AS. Multiple filters can be combined to narrow down results. This is useful for network operators and researchers analyzing routing data, investigating routing anomalies, or studying AS relationships.
BGP dumps in MRT format can be obtained from public route collectors. The tool processes these binary files efficiently, outputting matching BGP announcements in a human-readable or machine-parseable format.
Common use cases include tracking route propagation, identifying prefix hijacks, analyzing AS path lengths, and studying routing policy effects. The tool handles both IPv4 and IPv6 prefixes.

PARAMETERS

-p prefix

Match routes for the specified IP prefix.
-a asn
Match routes with the AS number anywhere in the path.
-o asn
Match routes with the specified origin AS.
-P pattern
Match AS path against the given pattern.
-m
Machine-readable output format.
-v
Invert match (show non-matching entries).
-c
Count matching entries.
-h
Display help information.

CAVEATS

Input must be in MRT format (common BGP dump format). Large dump files can take significant time to process. AS path matching patterns may have implementation-specific syntax. Memory usage scales with file size.

HISTORY

bgpgrep was developed as part of the BGP analysis toolset for network operators and researchers working with routing data. It complements other tools like bgpdump and bgpstream in the BGP data analysis ecosystem. The tool emerged from the need for efficient filtering of large-scale BGP datasets from route collectors.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community