bgpkit-commons
A Rust library for common BGP-related data and functions. Each data source is a
feature-gated module with lazy loading: call load_xxx() to fetch, then query.
Quick start
[]
= "0.13"
use BgpkitCommons;
let mut commons = new;
commons.load_bogons.unwrap;
assert!; // AS23456 is reserved
Data sources
| Module | Feature | Source | Data |
|---|---|---|---|
asinfo |
asinfo |
RIPE NCC, CAIDA, APNIC, IIJ IHR, PeeringDB, RIR delegated stats, IRR | AS names, countries, org mappings, population, hegemony, IRR registrations |
as2rel |
as2rel |
BGPKIT inference | AS-level provider/customer/peer relationships |
bogons |
bogons |
IANA special registries | Reserved/bogon ASN and IP prefix detection |
countries |
countries |
GeoNames | ISO country codes, capitals, continents, neighbors |
mrt_collectors |
mrt_collectors |
RouteViews, RIPE RIS | BGP collector metadata (name, project, country, dates) |
peeringdb |
peeringdb |
PeeringDB API | All 12 endpoints: networks, IXPs, facilities, orgs, carriers |
rpki |
rpki |
Cloudflare, RIPE NCC, RPKIviews, RPKISPOOL | ROA and ASPA validation (real-time and historical) |
delegated |
delegated |
NRO/RIR delegated stats | RIR allocation records (ASN, IPv4, IPv6) |
irr |
irr |
RIPE, APNIC, ARIN, LACNIC, AFRINIC, NTTCOM, RADB, ... | RPSL aut-num, route, route6, as-set records |
export |
export |
All of the above | Parquet export of every loaded data source |
Usage
AS information with enrichment
use AsInfoProfile;
use BgpkitCommons;
let mut commons = new;
commons.load_asinfo_with_profile.unwrap;
if let Ok = commons.asinfo_get
Fine-grained source selection
use BgpkitCommons;
let mut commons = new;
let builder = commons.asinfo_builder
.with_as2org
.with_peeringdb;
commons.load_asinfo_with.unwrap;
if let Ok = commons.asinfo_are_siblings
RPKI validation
use BgpkitCommons;
let mut commons = new;
commons.load_rpki.unwrap; // real-time Cloudflare data
let result = commons.rpki_validate.unwrap;
println!; // valid, invalid, or unknown
IRR source selection
use ;
let asinfo = new
.with_irr_sources
.build
.unwrap;
Bogon detection
use BgpkitCommons;
let mut commons = new;
commons.load_bogons.unwrap;
assert!; // RFC 1918
assert!; // reserved ASN
PeeringDB
use Peeringdb;
let pdb = new.unwrap; // all 12 endpoints
let cf = pdb.get_network.unwrap;
println!;
Direct module access
Modules work standalone without the BgpkitCommons facade:
use Bogons;
use Countries;
let bogons = new.unwrap;
let countries = new.unwrap;
Parquet export
The export feature enables source-faithful Parquet export of all loaded data.
Each upstream source is written as its own file with full source fields preserved.
[]
= { = "0.13", = ["export"] }
use BgpkitCommons;
use export;
let mut commons = new;
commons.load_countries.unwrap;
countries.unwrap;
// writes ./output/countries.parquet
CLI tool
The export-cli feature adds the bgpkit-export binary:
Output layout (one file per source):
commons-export/
manifest.json
asn_names.parquet
countries.parquet
iana_bogons.parquet
mrt_collectors.parquet
as_relationships.parquet
rir_delegated.parquet
peeringdb/ # 12 endpoint tables (--with-peeringdb)
irr/records.parquet # RPSL records (--with-irr)
rpki/ # ROAs + ASPAs (--with-rpki)
asninfo.jsonl # legacy merged output (--with-asninfo-jsonl)
Feature flags
| Feature | Description |
|---|---|
asinfo |
AS information with multi-source enrichment |
as2rel |
AS relationship inference data |
bogons |
Bogon prefix and ASN detection |
countries |
Country information lookup |
delegated |
RIR delegated-statistics parser |
irr |
IRR RPSL record parsing (aut-num, route, as-set) |
mrt_collectors |
MRT collector metadata |
peeringdb |
PeeringDB API data (all 12 endpoints) |
rpki |
RPKI validation (ROA and ASPA) |
all (default) |
Enables all data modules above |
export |
Parquet export of all loaded sources (adds arrow + parquet) |
export-cli |
Adds the bgpkit-export binary (adds clap + tracing-subscriber) |
Minimal build:
[]
= { = "0.13", = false, = ["bogons", "countries"] }
AsInfo loading profiles
| Profile | Sources | Use case |
|---|---|---|
Minimum |
RIPE asn.txt only |
Fast name/country lookup |
Default |
+ as2org, population, hegemony, PeeringDB | Production enrichment |
Full |
+ delegated stats, IRR (all sources, with route prefixes) | Complete dataset |
use AsInfoProfile;
// or build custom:
use AsInfoBuilder;
let builder = new
.with_as2org
.with_delegated
.with_irr;
License
MIT