Generates a combined BGP upstream topology diagram for any ASN, showing the paths from your network to Tier 1 ISPs through your upstream providers.
- Fetches all prefixes announced by the target ASN via RIPE stat
- Collects AS path data for each prefix from RIPE RIS route collectors
- Filters paths to confirmed upstreams only (drops peers and downstreams)
- Truncates each path at the outermost Tier 1 ASN, preserving intermediate hops
- Groups prefixes into policies (prefixes sharing identical path sets)
- Merges all policies into one diagram and renders it with Graphviz
Your AS → direct upstreams → intermediate transit → Tier 1 ISPs
# Debian / Ubuntu
apt install python3 python3-requests python3-graphviz graphviz
# or with pip
pip install requests graphviz# Default: AS215296, SVG output in ./output/
python3 bgp_topology.py
# Different ASN
python3 bgp_topology.py 64496
# PNG output
python3 bgp_topology.py --format png
# Write directly to a custom directory (e.g. a webserver folder)
python3 bgp_topology.py --output /var/www/html/bgp
python3 bgp_topology.py --output ~/public_html/bgp
# Skip AS name lookups (faster)
python3 bgp_topology.py --no-names
# Force fresh data (ignore cache)
python3 bgp_topology.py --no-cacheOutput is written to ./output/AS<ASN>_topology.<fmt>.
API responses are cached in .bgp_cache/ so re-runs are fast. Delete the directory to force a fresh fetch.
Tier 1 ASN names are defined in tier1_names.json — edit this file to match your preferred naming convention.
- Python 3.10+
requestsgraphviz(Python package + systemdotbinary)
Built with Claude by Anthropic.