# How to export BGP routing information (AS Path) in network flows | ntop

[Blog](https://www.ntop.org/blog/)[nProbe](https://www.ntop.org/category/nprobe/)

# How to export BGP routing information (AS Path) in network flows

February 28, 20192 min read

Tools like traceroute have been used for a long time to track the forward path of packets, i.e. the journey of our packets to a remote destination. Unfortunately with traceroute nothing can be said about the path of ingress packets, it not assuming that routing is symmetrical, fact that is often not correct. For this reason we have designed a solution that allows path information to be report in emitted flows. As the most popular exterior gateway protocol used on the internet is [BGP](https://en.wikipedia.org/wiki/Border_Gateway_Protocol), we have designed a tool that allows nProbe to receive BGP messages and use them to infer routing information. Using the nProbe BGP plugin it is possible to export the first ten Autonomous Systems (ASes) in both the AS-path to the client and to the server of each flow.

AS-paths, which are well-known mandatory BGP attributes, are determined by establishing a BGP session with a BGP-router. BGP sessions are established by an helper script `bgp_probe_client.pl` which encapsulates all of the functionality needed to establish and maintain a BGP peering session and exchange routing update information. Specifically, the script:

-   Establishes a BGP session with a BGP-router
-   Reads BGP updates to extract AS-paths
-   Sends AS-paths to nProbe[![](/images/2019/02/nprobe_plugins_bgp.webp)](https://www.ntop.org/images/2019/02/nprobe_plugins_bgp.webp)

The script is opensource and can be downloaded from [GitHub](https://github.com/ntop/nProbe/tree/master/bgp).

nProbe uses AS-paths received from the script to export additional elements `SRC_AS_PATH_1, ..., SRC_AS_PATH_1`0 and `DST_AS_PATH_1, ..., DST_AS_PATH_10`, indicating up to the first 10 ASes in the AS-path to the client and to the server. Those elements can be specified in the nProbe template (option `-T`) as any other regular element.

So for example, one can export the first 8 ASes of the client and the server of flows monitored from interface `eth1` as follows:

sudo ./nprobe --bgp-port 9999 --zmq "tcp://\*:5556" -i eth1 -n none -T "@NTOPNG@ %SRC\_TOS %DST\_TOS %INPUT\_SNMP %OUTPUT\_SNMP %SRC\_AS\_PATH\_1 %SRC\_AS\_PATH\_2 %SRC\_AS\_PATH\_3 %SRC\_AS\_PATH\_4 %SRC\_AS\_PATH\_5 %SRC\_AS\_PH\_6 %SRC\_AS\_PATH\_7 %SRC\_AS\_PATH\_8 %DST\_AS\_PATH\_1 %DST\_AS\_PATH\_2 %DST\_AS\_PATH\_3 %DST\_AS\_PATH\_4 %DST\_AS\_PATH\_5 %DST\_AS\_PATH\_6 %DST\_AS\_PATH\_7 %DST\_AS\_PATH\_8"

Apart from the well-known options, the extra `--bgp-port 9999` is required for the communications between nProbe and the `bgp_probe_client.pl`.

For an in-depth description of the plugin, refer to the official [nProbe documentation](https://www.ntop.org/guides/nprobe/bgp.html). Keep in mind that the BGP plugin also works when nProbe is collector mode.

## Keep reading

AnnounceSep 9, 2026

### [nProbe 11.2: BGP/BMP Support, OT Protocols, Faster Flow Collection](https://www.ntop.org/nprobe-11-2-bgp-bmp-support-ot-protocols-faster-flow-collection/)

We are pleased to announce the release of nProbe 11.2, bringing major new capabilities for network visibility, routing intelligence, flow analysis, and OT monitoring. This release significantly expands nProbe beyond traditional flow…

nProbeAug 12, 2026

### [HowTo Collect Flows: the Case of Palo Alto and Fortinet](https://www.ntop.org/howto-collect-flows-the-case-of-palo-alto-and-fortigate/)

Network devices export flow data in many flavors. Some vendors stick closely to the NetFlow/IPFIX standard, so collecting their flows is essentially plug-and-play. Others extend the standard with proprietary Information Elements (IEs)…

nProbeJun 4, 2026

### [Observability: Enabling High-Resolution Timeseries in ntopng](https://www.ntop.org/observability-enabling-high-resolution-timeseries-in-ntopng/)

Modern observability platforms are expected to answer questions that traditional monitoring systems were never designed to handle: What exactly happened during that 20-second congestion spike? Which application caused the transient burst? Why…

## Try it on your own network

Download the free Community edition and see your first flows in five minutes.

[Download ntopng free](https://www.ntop.org/support/documentation/software-installation/)[Talk to an engineer](https://www.ntop.org/support/need-help/contacts/)
Source: https://www.ntop.org/how-to-export-bgp-routing-information-as-path-in-network-flows/