Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

bgp-network-policy

Generates a combined BGP upstream topology diagram for any ASN, showing the paths from your network to Tier 1 ISPs through your upstream providers.

What it does

  1. Fetches all prefixes announced by the target ASN via RIPE stat
  2. Collects AS path data for each prefix from RIPE RIS route collectors
  3. Filters paths to confirmed upstreams only (drops peers and downstreams)
  4. Truncates each path at the outermost Tier 1 ASN, preserving intermediate hops
  5. Groups prefixes into policies (prefixes sharing identical path sets)
  6. Merges all policies into one diagram and renders it with Graphviz

Example output

Your AS → direct upstreams → intermediate transit → Tier 1 ISPs

Installation

# Debian / Ubuntu
apt install python3 python3-requests python3-graphviz graphviz

# or with pip
pip install requests graphviz

Usage

# 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-cache

Output 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 names

Tier 1 ASN names are defined in tier1_names.json — edit this file to match your preferred naming convention.

Dependencies

  • Python 3.10+
  • requests
  • graphviz (Python package + system dot binary)

Credits

Built with Claude by Anthropic.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages