Shield Base
BGP / ASN
Autonomous System Numbers and prefix routing data from BGP.tools, compiled into asn.mmdb with classification and hit count metadata.
The BGP source fetches ASN definitions and routing table data from BGP.tools and compiles them into a single MMDB database. Each record maps a CIDR prefix to its Autonomous System, including the AS name, classification, and route visibility (hit count). Routes with fewer than 10 hits are filtered out.
Output file: asn.mmdb
Data Sources
- ASN definitions CSV: bgp.tools/asns.csv
- BGP routing table JSONL: bgp.tools/table.jsonl
BGP.tools requires a valid contact User-Agent in the format
<name> [url] - <email>. You must provide this via the interactive wizard or the --contact flag to avoid API blocking.Usage
pnpm dlx @riavzon/shield-base --bgp --contact "Your Name https://example.com - [email protected]"
yarn dlx @riavzon/shield-base --bgp --contact "Your Name https://example.com - [email protected]"
npx @riavzon/shield-base --bgp --contact "Your Name https://example.com - [email protected]"
bunx @riavzon/shield-base --bgp --contact "Your Name https://example.com - [email protected]"
import { getBGPAndASN } from '@riavzon/shield-base';
await getBGPAndASN('Your Name https://example.com - [email protected]', './out', 'mmdbctl');
Record Structure
interface BgpRecord {
range: string; // CIDR prefix, e.g. "8.8.8.0/24"
asn_id: string; // AS number, e.g. "15169"
asn_name: string; // AS name, e.g. "Google LLC"
classification: string; // "Content" | "Eyeballs" | "Unknown"
hits: string; // Route visibility count
}
Example Lookup
Terminal
mmdbctl read -f json-pretty 8.8.8.8 outputDirectory/asn.mmdb
{
"asn_id": "15169",
"asn_name": "Google LLC",
"classification": "Content",
"hits": "2679",
"ip": "8.8.8.8",
"network": "8.8.8.0/24"
}