Skip to content

bgpkit/monocle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Monocle

Rust Crates.io Docs.rs License

See through all Border Gateway Protocol (BGP) data with a monocle.

Table of Contents

Install

Using cargo

cargo install monocle

Using homebrew on macOS

brew install monocle

Install cargo-binstall first:

cargo install cargo-binstall

Then install monocle using cargo binstall

cargo binstall monocle

Using Docker

Pull the pre-built image or build locally:

# Build the image locally
docker build -t bgpkit/monocle:latest .

# Or use docker compose
docker compose build

Run monocle commands:

# Show help
docker run --rm bgpkit/monocle:latest

# Run a command (e.g., inspect an ASN)
docker run --rm bgpkit/monocle:latest inspect 13335

# Run with persistent data directory
docker run --rm -v monocle-data:/data bgpkit/monocle:latest inspect 13335

# Start the WebSocket server
docker run --rm -p 8080:8080 -v monocle-data:/data bgpkit/monocle:latest server --address 0.0.0.0 --port 8080

# Using docker compose for server mode
docker compose up -d

Library Usage

Monocle can also be used as a library in your Rust projects. Add it to your Cargo.toml:

[dependencies]
# Full library with CLI argument support (default)
monocle = "1.0"

# Minimal database access only
monocle = { version = "1.0", default-features = false, features = ["database"] }

# BGP operations without CLI overhead
monocle = { version = "1.0", default-features = false, features = ["lens-bgpkit"] }

# Full functionality without CLI
monocle = { version = "1.0", default-features = false, features = ["lens-full"] }

Feature Tiers

Monocle's features are organized in tiers for minimal dependency footprint:

Feature Description Key Dependencies
database SQLite operations only rusqlite, oneio, ipnet, chrono
lens-core Standalone lenses (TimeLens) chrono-humanize, dateparser
lens-bgpkit BGP-related lenses bgpkit-*, rayon, tabled
lens-full All lenses including InspectLens All above
cli (default) Full CLI binary with server axum, tokio, tower-http

Architecture

The library is organized into the following core modules:

  • database: All database functionality

    • core: Connection management and schema definitions
    • session: One-time storage for search results
    • monocle: Main monocle database with ASInfo, AS2Rel, RPKI, and Pfx2as caching
  • lens: High-level business logic (reusable across CLI, API, GUI)

    • time: Time parsing and formatting lens (lens-core)
    • country: Country code/name lookup lens (lens-bgpkit)
    • ip: IP information lookup lens (lens-bgpkit)
    • parse: MRT file parsing lens with progress tracking (lens-bgpkit)
    • search: BGP message search lens with progress tracking (lens-bgpkit)
    • rpki: RPKI validation and data lens (lens-bgpkit)
    • pfx2as: Prefix-to-AS mapping types (lens-bgpkit)
    • as2rel: AS-level relationships lens (lens-bgpkit)
    • inspect: Unified AS/prefix inspection lens (lens-full)
  • server: WebSocket API server (cli feature)

For detailed architecture documentation, see ARCHITECTURE.md.

Example: Using Lenses

use monocle::database::MonocleDatabase;
use monocle::lens::inspect::{InspectLens, InspectQueryOptions};

fn main() -> anyhow::Result<()> {
    // Open the monocle database
    let db = MonocleDatabase::open_in_dir("~/.monocle")?;
    
    // Create a lens
    let lens = InspectLens::new(&db);
    
    // Query AS information
    let options = InspectQueryOptions::default();
    let results = lens.query_asn(13335, &options)?;
    
    println!("AS{}: {}", results.asn, results.name.unwrap_or_default());
    
    Ok(())
}

Example: Parse MRT Files with Progress

use monocle::lens::parse::{ParseLens, ParseFilters, ParseProgress};
use std::sync::Arc;

fn main() -> anyhow::Result<()> {
    let lens = ParseLens::new();
    let filters = ParseFilters::default();
    
    // Define a progress callback
    let callback = Arc::new(|progress: ParseProgress| {
        match progress {
            ParseProgress::Started { file_path } => {
                eprintln!("Started parsing: {}", file_path);
            }
            ParseProgress::Update { messages_processed, rate, .. } => {
                eprintln!("Processed {} messages ({:.0} msg/s)", 
                    messages_processed, rate.unwrap_or(0.0));
            }
            ParseProgress::Completed { total_messages, duration_secs, .. } => {
                eprintln!("Completed: {} messages in {:.2}s", total_messages, duration_secs);
            }
        }
    });
    
    // Parse with progress tracking
    let elems = lens.parse_with_progress(
        &filters, 
        "path/to/file.mrt", 
        Some(callback)
    )?;
    
    for elem in elems {
        println!("{:?}", elem);
    }
    
    Ok(())
}

Usage

Subcommands:

  • parse: parse individual MRT files
  • search: search for matching messages from all available public MRT files
  • server: start a WebSocket server for programmatic access
  • inspect: unified AS and prefix information lookup
  • country: utility to look up country name and code
  • time: utility to convert time between unix timestamp and RFC3339 string
  • as2rel: AS-level relationship lookup between ASNs
  • pfx2as: prefix-to-ASN mapping lookup with RPKI validation
  • rpki: RPKI validation and ROA/ASPA listing
  • ip: IP information lookup
  • config: configuration display and database management (refresh, backup, sources)

Global Options

All commands support the following global options:

  • --format <FORMAT>: Output format (table, markdown, json, json-pretty, json-line, psv)
  • --json: Shortcut for --format json-pretty
  • --debug: Print debug information

Top-level help menu:

โžœ  ~ monocle                      
A commandline application to search, parse, and process BGP information in public sources.


Usage: monocle [OPTIONS] <COMMAND>

Commands:
  parse    Parse individual MRT files given a file path, local or remote
  search   Search BGP messages from all available public MRT files
  server   Start the WebSocket server (ws://<address>:<port>/ws, health: http://<address>:<port>/health)
  inspect  Unified AS and prefix information lookup
  country  Country name and code lookup utilities
  time     Time conversion utilities
  rpki     RPKI utilities
  ip       IP information lookup
  as2rel   AS-level relationship lookup between ASNs
  config   Show monocle configuration, data paths, and database management
  help     Print this message or the help of the given subcommand(s)

Options:
  -c, --config <CONFIG>  configuration file path, by default $HOME/.monocle.toml is used
      --debug            Print debug information
      --format <FORMAT>  Output format: table (default), markdown, json, json-pretty, json-line, psv
      --json             Output as JSON objects (shortcut for --format json-pretty)
  -h, --help             Print help
  -V, --version          Print version

monocle parse

Parsing a single MRT file given a local path or a remote URL.

โžœ  monocle parse --help
Parse individual MRT files given a file path, local or remote

Usage: monocle parse [OPTIONS] <FILE>

Arguments:
  <FILE>  File path to a MRT file, local or remote

Options:
      --debug                    Print debug information
      --format <FORMAT>          Output format: table (default), markdown, json, json-pretty, json-line, psv
      --json                     Output as JSON objects (shortcut for --format json-pretty)
  -M, --mrt-path <MRT_PATH>      MRT output file path
  -o, --origin-asn <ORIGIN_ASN>  Filter by origin AS Number
  -p, --prefix <PREFIX>          Filter by network prefix
  -s, --include-super            Include super-prefix when filtering
  -S, --include-sub              Include sub-prefix when filtering
  -j, --peer-ip <PEER_IP>        Filter by peer IP address
  -J, --peer-asn <PEER_ASN>      Filter by peer ASN
  -m, --elem-type <ELEM_TYPE>    Filter by elem type: announce (a) or withdraw (w)
  -t, --start-ts <START_TS>      Filter by start unix timestamp inclusive
  -T, --end-ts <END_TS>          Filter by end unix timestamp inclusive
  -h, --help                     Print help

Example: parse a remote MRT file and show only announcements for a specific prefix:

โžœ  monocle parse https://data.ris.ripe.net/rrc00/2024.01/updates.20240101.0000.gz \
    -p 1.1.1.0/24 -m a | head -5
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ type     โ”‚ timestamp           โ”‚ peer_ip                   โ”‚ peer_asn โ”‚ prefix     โ”‚ as_path                                   โ”‚ origin โ”‚ origin_asns โ”‚ next_hop                  โ”‚ local_pref โ”‚ med โ”‚ communities โ”‚ atomic โ”‚ aggr_asn โ”‚ aggr_ip โ”‚ only_to_customer โ”‚ unknown โ”‚ deprecated โ”‚ collector โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ announce โ”‚ 2024-01-01 00:00:44 โ”‚ 2001:7f8:4::9d85:1        โ”‚ 40325    โ”‚ 1.1.1.0/24 โ”‚ 40325 13335                               โ”‚ IGP    โ”‚ 13335       โ”‚ 2001:7f8:4::9d85:1        โ”‚            โ”‚     โ”‚             โ”‚ false  โ”‚          โ”‚         โ”‚                  โ”‚         โ”‚            โ”‚           โ”‚
โ”‚ announce โ”‚ 2024-01-01 00:00:50 โ”‚ 2001:7f8:4::3:2e8b:1      โ”‚ 208571   โ”‚ 1.1.1.0/24 โ”‚ 208571 6939 13335                         โ”‚ IGP    โ”‚ 13335       โ”‚ 2001:7f8:4::3:2e8b:1      โ”‚            โ”‚     โ”‚             โ”‚ false  โ”‚          โ”‚         โ”‚                  โ”‚         โ”‚            โ”‚           โ”‚

Output Format

The output contains the following fields:

Field Description
type Message type: announce or withdraw
timestamp Message timestamp in UTC
peer_ip IP address of the BGP peer
peer_asn ASN of the BGP peer
prefix Network prefix being announced/withdrawn
as_path AS path (space-separated)
origin Origin type: IGP, EGP, or INCOMPLETE
origin_asns Origin AS number(s)
next_hop Next hop IP address
local_pref Local preference value
med Multi-exit discriminator
communities BGP communities
atomic Atomic aggregate flag
aggr_asn Aggregator ASN
aggr_ip Aggregator IP
only_to_customer OTC attribute (RFC 9234)
unknown Unknown attributes
deprecated Deprecated attributes
collector Collector name (for search results)

JSON output example:

{
  "type": "announce",
  "timestamp": "2024-01-01T00:00:44Z",
  "peer_ip": "2001:7f8:4::9d85:1",
  "peer_asn": 40325,
  "prefix": "1.1.1.0/24",
  "as_path": "40325 13335",
  "origin": "IGP",
  "origin_asns": [13335],
  "next_hop": "2001:7f8:4::9d85:1",
  "local_pref": null,
  "med": null,
  "communities": [],
  "atomic": false,
  "aggr_asn": null,
  "aggr_ip": null,
  "only_to_customer": null,
  "unknown": null,
  "deprecated": null,
  "collector": null
}

monocle search

Search for BGP messages from all available public MRT files using BGPKIT Broker.

โžœ  monocle search --help
Search BGP messages from all available public MRT files

Usage: monocle search [OPTIONS] --start-ts <START_TS> --end-ts <END_TS>

Options:
      --debug                        Print debug information
      --format <FORMAT>              Output format: table (default), markdown, json, json-pretty, json-line, psv
      --json                         Output as JSON objects (shortcut for --format json-pretty)
  -t, --start-ts <START_TS>          Start timestamp (RFC3339 or Unix)
  -T, --end-ts <END_TS>              End timestamp (RFC3339 or Unix)
  -c, --collector <COLLECTOR>        Filter by collector name
      --project <PROJECT>            Filter by project (riperis, routeviews)
  -d, --dump-type <DUMP_TYPE>        Dump type: updates or rib [default: updates]
  -o, --origin-asn <ORIGIN_ASN>      Filter by origin AS Number
  -p, --prefix <PREFIX>              Filter by network prefix
  -s, --include-super                Include super-prefix when filtering
  -S, --include-sub                  Include sub-prefix when filtering
  -j, --peer-ip <PEER_IP>            Filter by peer IP address
  -J, --peer-asn <PEER_ASN>          Filter by peer ASN
  -m, --elem-type <ELEM_TYPE>        Filter by elem type: announce (a) or withdraw (w)
      --as-path <AS_PATH>            Filter by AS path regex
      --broker-files                 Show broker file list only (don't parse)
  -h, --help                         Print help

Example: search for BGP announcements for a prefix during a specific time window:

โžœ  monocle search -t 2024-01-01T00:00:00Z -T 2024-01-01T00:01:00Z \
    -c rrc00 -p 1.1.1.0/24 -m a

Use --broker-files to see the list of MRT files that would be queried without actually parsing them:

โžœ  monocle search -t 2024-01-01T00:00:00Z -T 2024-01-01T01:00:00Z \
    -c rrc00 --broker-files

monocle time

Parse and convert time strings between various formats.

โžœ  monocle time --help
Time conversion utilities

Usage: monocle time [OPTIONS] [TIMES]...

Arguments:
  [TIMES]...  Time strings to parse (Unix timestamp, RFC3339, or human-readable)

Options:
      --debug            Print debug information
      --format <FORMAT>  Output format: table (default), markdown, json, json-pretty, json-line, psv
      --json             Output as JSON objects (shortcut for --format json-pretty)
  -h, --help             Print help

Examples:

โžœ  monocle time 1704067200
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ unix       โ”‚ rfc3339              โ”‚ human                               โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1704067200 โ”‚ 2024-01-01T00:00:00Z โ”‚ Mon, Jan 1, 2024 at 12:00:00 AM UTC โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โžœ  monocle time "2024-01-01T00:00:00Z"
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ unix       โ”‚ rfc3339              โ”‚ human                               โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1704067200 โ”‚ 2024-01-01T00:00:00Z โ”‚ Mon, Jan 1, 2024 at 12:00:00 AM UTC โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โžœ  monocle time "yesterday" "last week"

monocle inspect

Unified AS and prefix information lookup. Replaces the former whois and pfx2as commands.

By default, inspect shows all available information for ASN and prefix queries, including:

  • Basic: AS name, country, organization, and PeeringDB info (website, IRR AS-SET)
  • Prefixes: Announced prefixes with RPKI validation status
  • Connectivity: AS relationships (upstreams, peers, downstreams)
  • RPKI: ROAs and ASPA records

When querying multiple ASNs, a glance table is automatically shown first, providing a quick overview of all queried ASNs before the detailed per-ASN information.

โžœ  monocle inspect --help
Unified AS and prefix information lookup

Usage: monocle inspect [OPTIONS] [QUERY]...

Arguments:
  [QUERY]...  One or more queries: ASN (13335, AS13335), prefix (1.1.1.0/24), IP (1.1.1.1), or name (cloudflare)

Options:
  -a, --asn                Force treat queries as ASNs
      --debug              Print debug information
  -p, --prefix             Force treat queries as prefixes
      --format <FORMAT>    Output format: table (default), markdown, json, json-pretty, json-line, psv
  -n, --name               Force treat queries as name search
  -c, --country <COUNTRY>  Search by country code (e.g., US, DE)
      --json               Output as JSON objects (shortcut for --format json-pretty)
      --show <SECTION>     Select data sections to display (can be repeated). Available: basic, prefixes, connectivity, rpki, all
      --full               Show all data sections with no limits
      --full-roas          Show all RPKI ROAs (default: top 10)
      --full-prefixes      Show all prefixes (default: top 10)
      --full-connectivity  Show all neighbors (default: top 5 per category)
      --limit <N>          Limit search results (default: 20)
  -u, --update             Force refresh the asinfo database
  -h, --help               Print help

Examples:

# Look up AS by number (shows all information by default)
โžœ  monocle inspect 13335
Query: 13335 (type: asn)
โ”€โ”€โ”€ Basic Information โ”€โ”€โ”€
ASN:     AS13335
Name:    CLOUDFLARENET
Country: US
Org:     Cloudflare, Inc.
Org ID:  CLOUD14-ARIN
Website: https://www.cloudflare.com
AS-SET:     AS13335:AS-CLOUDFLARE

โ”€โ”€โ”€ Announced Prefixes โ”€โ”€โ”€
Total: 5526 (2409 IPv4, 3117 IPv6)
RPKI Validation: valid 5071 (91.8%), invalid 1 (0.0%), unknown 454 (8.2%)
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Prefix              โ”‚ Validation โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 103.186.74.0/24     โ”‚ unknown    โ”‚
โ”‚ ...                 โ”‚ ...        โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
(showing 10 of 5526 prefixes, use --full-prefixes to show all)

โ”€โ”€โ”€ Connectivity โ”€โ”€โ”€
...
(results truncated, use --full-connectivity to show all)

โ”€โ”€โ”€ RPKI โ”€โ”€โ”€
ROAs: 4420 total (2754 IPv4, 1666 IPv6)
...
(ROA list truncated, use --full-roas to show all)

# Query multiple ASNs (glance table shown first)
โžœ  monocle inspect 13335 15169
โ”€โ”€โ”€ Glance โ”€โ”€โ”€
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ ASN     โ”‚ Name          โ”‚ Country โ”‚ Org              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ AS13335 โ”‚ CLOUDFLARENET โ”‚ US      โ”‚ Cloudflare, Inc. โ”‚
โ”‚ AS15169 โ”‚ GOOGLE        โ”‚ US      โ”‚ Google LLC       โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Query: 13335 (type: asn)
โ”€โ”€โ”€ Basic Information โ”€โ”€โ”€
...

# Search by name
โžœ  monocle inspect -n cloudflare
Query: cloudflare (type: name)

โ”€โ”€โ”€ Search Results โ”€โ”€โ”€
Found: 5 matches
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ ASN    โ”‚ Name                       โ”‚ Country โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 13335  โ”‚ CLOUDFLARENET              โ”‚ US      โ”‚
โ”‚ ...    โ”‚ ...                        โ”‚ ...     โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

# Look up prefix
โžœ  monocle inspect 1.1.1.0/24
Query: 1.1.1.0/24 (type: prefix)

โ”€โ”€โ”€ Announced Prefix โ”€โ”€โ”€
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Matched Prefix โ”‚ Match Type โ”‚ ASN     โ”‚ Validation โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1.1.1.0/24     โ”‚ exact      โ”‚ AS13335 โ”‚ valid      โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ”€โ”€โ”€ Covering ROAs โ”€โ”€โ”€
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Prefix     โ”‚ Max Length โ”‚ Origin ASN โ”‚ TA    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1.1.1.0/24 โ”‚ 24         โ”‚ AS13335    โ”‚ APNIC โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

# Show only basic information
โžœ  monocle inspect 13335 --show basic

monocle country

Look up country names and codes.

โžœ  monocle country --help
Country name and code lookup utilities

Usage: monocle country [OPTIONS] <QUERY>

Arguments:
  <QUERY>  Country code (2-letter) or name to search

Options:
      --debug            Print debug information
      --format <FORMAT>  Output format: table (default), markdown, json, json-pretty, json-line, psv
      --json             Output as JSON objects (shortcut for --format json-pretty)
  -h, --help             Print help

Examples:

โžœ  monocle country US
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ code โ”‚ name          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ US   โ”‚ United States โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โžœ  monocle country germany
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ code โ”‚ name    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ DE   โ”‚ Germany โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

monocle as2rel

Look up AS-level relationships between ASNs using BGPKIT's AS relationship data.

โžœ  monocle as2rel --help
AS-level relationship lookup between ASNs

Usage: monocle as2rel [OPTIONS] <ASNS>...

Arguments:
  <ASNS>...  One or more ASNs to query relationships for
             - Single ASN: shows all relationships for that ASN
             - Two ASNs: shows the relationship between them
             - Multiple ASNs: shows relationships for all pairs (asn1 < asn2)

Options:
      --debug                Print debug information
      --format <FORMAT>      Output format: table (default), markdown, json, json-pretty, json-line, psv
      --json                 Output as JSON objects (shortcut for --format json-pretty)
      --update               Force update the local database
      --no-explain           Hide the explanation text in table output
      --sort-by-asn          Sort results by ASN2 ascending (default: sort by connected % descending)
      --show-name            Show organization name for ASN2 (truncated to 20 chars)
      --show-full-name       Show full organization name without truncation
      --min-visibility <PCT> Minimum visibility percentage (0-100) to include in results
      --single-homed         Only show ASNs that are single-homed to the queried ASN
      --is-upstream          Only show relationships where the queried ASN is an upstream (provider)
      --is-downstream        Only show relationships where the queried ASN is a downstream (customer)
      --is-peer              Only show peer relationships
  -h, --help                 Print help

Output columns:

  • asn1 / asn2: The two ASNs being compared
  • connected: Percentage of peers that see any connection between the ASNs
  • peer: Percentage seeing pure peering relationship
  • as1_upstream: Percentage seeing ASN1 as upstream of ASN2
  • as2_upstream: Percentage seeing ASN2 as upstream of ASN1

Examples:

# Look up relationship between two ASNs
โžœ  monocle as2rel 13335 174
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ asn1  โ”‚ asn2 โ”‚ connected โ”‚ peer  โ”‚ as1_upstreamโ”‚ as2_upstreamโ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 13335 โ”‚ 174  โ”‚ 95.2%     โ”‚ 85.1% โ”‚ 2.3%        โ”‚ 7.8%        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

# Show all relationships for an ASN with names
โžœ  monocle as2rel 13335 --show-name | head -10

# Find ASNs that are single-homed to AS2914 (NTT)
โžœ  monocle as2rel 2914 --single-homed --show-name

# Find single-homed ASNs with at least 10% visibility
โžœ  monocle as2rel 2914 --single-homed --min-visibility 10

# Show only downstream customers of an ASN
โžœ  monocle as2rel 2914 --is-upstream --show-name

# Show only upstream providers of an ASN
โžœ  monocle as2rel 13335 --is-downstream --show-name

# Show relationships among multiple ASNs (all pairs)
โžœ  monocle as2rel 174 2914 3356 --show-name

monocle pfx2as

Look up prefix-to-ASN mappings. Query by prefix to find origin ASNs, or by ASN to find announced prefixes. Results include RPKI validation status for each prefix-ASN pair.

โžœ  monocle pfx2as --help
Prefix-to-ASN mapping lookup

Query by prefix to find origin ASNs, or by ASN to find announced prefixes.
Includes RPKI validation status for each prefix-ASN pair.

Usage: monocle pfx2as [OPTIONS] <QUERY>

Arguments:
  <QUERY>  Query: an IP prefix (e.g., 1.1.1.0/24) or ASN (e.g., 13335, AS13335)

Options:
  -u, --update           Force update the local pfx2as database
      --include-sub      Include sub-prefixes (more specific) in results when querying by prefix
      --include-super    Include super-prefixes (less specific) in results when querying by prefix
      --show-name        Show AS name for each origin ASN
      --show-full-name   Show full AS name without truncation (default truncates to 20 chars)
  -l, --limit <N>        Limit the number of results (default: no limit)
      --debug            Print debug information
      --format <FORMAT>  Output format: table (default), markdown, json, json-pretty, json-line, psv
      --json             Output as JSON objects (shortcut for --format json-pretty)
  -h, --help             Print help

Examples:

# Look up a prefix - shows origin ASN and RPKI validation status
โžœ  monocle pfx2as 1.1.1.0/24
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ prefix     โ”‚ origin_asn โ”‚ rpki  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1.1.1.0/24 โ”‚ 13335      โ”‚ valid โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

# Look up with AS name
โžœ  monocle pfx2as 1.1.1.0/24 --show-name
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ prefix     โ”‚ origin_asn โ”‚ as_name       โ”‚ rpki  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1.1.1.0/24 โ”‚ 13335      โ”‚ CLOUDFLARENET โ”‚ valid โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

# Look up by ASN - shows all prefixes announced by the ASN
โžœ  monocle pfx2as 13335 --limit 5 --show-name
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ prefix              โ”‚ origin_asn โ”‚ as_name       โ”‚ rpki      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 172.69.7.0/24       โ”‚ 13335      โ”‚ CLOUDFLARENET โ”‚ valid     โ”‚
โ”‚ 2606:4700:839a::/48 โ”‚ 13335      โ”‚ CLOUDFLARENET โ”‚ valid     โ”‚
โ”‚ 8.36.218.0/24       โ”‚ 13335      โ”‚ CLOUDFLARENET โ”‚ not_found โ”‚
โ”‚ 2400:cb00:b8e6::/48 โ”‚ 13335      โ”‚ CLOUDFLARENET โ”‚ valid     โ”‚
โ”‚ 172.68.134.0/24     โ”‚ 13335      โ”‚ CLOUDFLARENET โ”‚ valid     โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

# Include sub-prefixes (more specific prefixes)
โžœ  monocle pfx2as 8.8.0.0/16 --include-sub --limit 5 --show-name
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ prefix       โ”‚ origin_asn โ”‚ as_name    โ”‚ rpki      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 8.0.0.0/12   โ”‚ 3356       โ”‚ LEVEL3     โ”‚ not_found โ”‚
โ”‚ 8.8.8.0/24   โ”‚ 15169      โ”‚ GOOGLE     โ”‚ valid     โ”‚
โ”‚ 8.8.249.0/24 โ”‚ 989        โ”‚ ANAXA3-ASN โ”‚ valid     โ”‚
โ”‚ 8.8.216.0/24 โ”‚ 13781      โ”‚ ENERGYNET  โ”‚ valid     โ”‚
โ”‚ 8.8.64.0/24  โ”‚ 3356       โ”‚ LEVEL3     โ”‚ not_found โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

# Include super-prefixes (less specific prefixes)
โžœ  monocle pfx2as 1.1.1.0/24 --include-super

# JSON output
โžœ  monocle pfx2as 13335 --limit 3 --json
[
  {
    "prefix": "172.69.7.0/24",
    "origin_asn": 13335,
    "rpki": "valid"
  },
  {
    "prefix": "2606:4700:839a::/48",
    "origin_asn": 13335,
    "rpki": "valid"
  },
  {
    "prefix": "8.36.218.0/24",
    "origin_asn": 13335,
    "rpki": "not_found"
  }
]

monocle rpki

RPKI utilities for validation and listing ROAs/ASPAs.

Data sources:

โžœ  monocle rpki --help
RPKI utilities

Usage: monocle rpki [OPTIONS] <COMMAND>

Commands:
  validate  validate a prefix-asn pair using cached RPKI data
  roas      list ROAs from RPKI data (current or historical via bgpkit-commons)
  aspas     list ASPAs from RPKI data (current or historical via bgpkit-commons)
  help      Print this message or the help of the given subcommand(s)

Options:
      --debug            Print debug information
      --format <FORMAT>  Output format: table (default), markdown, json, json-pretty, json-line, psv
      --json             Output as JSON objects (shortcut for --format json-pretty)
  -h, --help             Print help

monocle rpki validate

Validate a prefix-ASN pair against cached RPKI data. Implements RFC 6811 validation logic:

  • Valid: Covering ROA exists with matching ASN and prefix length โ‰ค max_length
  • Invalid: Covering ROA exists but ASN doesn't match or prefix length exceeds max_length
  • NotFound: No covering ROA exists for the prefix
โžœ  monocle rpki validate --help
validate a prefix-asn pair using cached RPKI data

Usage: monocle rpki validate [OPTIONS] <RESOURCES>...

Arguments:
  <RESOURCES>...  Two resources: one prefix and one ASN (order does not matter)

Options:
  -r, --refresh  Force refresh the RPKI cache before validation
  -h, --help     Print help

Examples:

โžœ  monocle rpki validate 1.1.1.0/24 13335
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ prefix     โ”‚ asn   โ”‚ status โ”‚ reason                            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1.1.1.0/24 โ”‚ 13335 โ”‚ Valid  โ”‚ Covered by ROA: 1.1.1.0/24-24     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โžœ  monocle rpki validate 1.1.1.0/24 12345
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ prefix     โ”‚ asn   โ”‚ status  โ”‚ reason                                     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1.1.1.0/24 โ”‚ 12345 โ”‚ Invalid โ”‚ ASN mismatch: ROA allows 13335, got 12345  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

monocle rpki roas

List ROAs from RPKI data. Supports both current (cached from Cloudflare) and historical data.

โžœ  monocle rpki roas --help
list ROAs from RPKI data (current or historical via bgpkit-commons)

Usage: monocle rpki roas [OPTIONS] [RESOURCES]...

Arguments:
  [RESOURCES]...  Filter by resources (prefixes or ASNs, auto-detected)

Options:
      --date <DATE>            Load historical data for this date (YYYY-MM-DD)
      --source <SOURCE>        Historical data source: ripe, rpkiviews [default: ripe]
      --collector <COLLECTOR>  RPKIviews collector: soborost, massars, attn, kerfuffle [default: soborost]
  -r, --refresh                Force refresh the RPKI cache (only applies to current data)
  -h, --help                   Print help

Examples:

# List ROAs for an ASN (current data)
โžœ  monocle rpki roas 13335
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ asn   โ”‚ prefix              โ”‚ max_length โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 13335 โ”‚ 1.0.0.0/24          โ”‚ 24         โ”‚
โ”‚ 13335 โ”‚ 1.1.1.0/24          โ”‚ 24         โ”‚
โ”‚ ...   โ”‚ ...                 โ”‚ ...        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

# List ROAs for a prefix
โžœ  monocle rpki roas 1.1.1.0/24
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ asn   โ”‚ prefix     โ”‚ max_length โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 13335 โ”‚ 1.1.1.0/24 โ”‚ 24         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

# Historical data from a specific date
โžœ  monocle rpki roas 13335 --date 2024-01-01 --source ripe

monocle rpki aspas

List ASPAs (Autonomous System Provider Authorizations) from RPKI data.

โžœ  monocle rpki aspas --help
list ASPAs from RPKI data (current or historical via bgpkit-commons)

Usage: monocle rpki aspas [OPTIONS]

Options:
      --customer <CUSTOMER>    Filter by customer ASN
      --provider <PROVIDER>    Filter by provider ASN
      --date <DATE>            Load historical data for this date (YYYY-MM-DD)
      --source <SOURCE>        Historical data source: ripe, rpkiviews [default: ripe]
      --collector <COLLECTOR>  RPKIviews collector: soborost, massars, attn, kerfuffle [default: soborost]
  -r, --refresh                Force refresh the RPKI cache (only applies to current data)
  -h, --help                   Print help

Examples:

# List all ASPAs
โžœ  monocle rpki aspas | head -10

# Filter by customer ASN
โžœ  monocle rpki aspas --customer 13335

# Filter by provider ASN
โžœ  monocle rpki aspas --provider 174

monocle ip

Look up information about IP addresses.

โžœ  monocle ip --help
IP information lookup

Usage: monocle ip [OPTIONS] [IP]

Arguments:
  [IP]  IP address to look up (omit to get your public IP)

Options:
      --debug            Print debug information
      --format <FORMAT>  Output format: table (default), markdown, json, json-pretty, json-line, psv
      --json             Output as JSON objects (shortcut for --format json-pretty)
  -h, --help             Print help

Examples:

# Look up a specific IP
โžœ  monocle ip 1.1.1.1
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Field       โ”‚ Value                                           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ ip          โ”‚ 1.1.1.1                                         โ”‚
โ”‚ asn         โ”‚ 13335                                           โ”‚
โ”‚ as_name     โ”‚ CLOUDFLARENET                                   โ”‚
โ”‚ country     โ”‚ AU                                              โ”‚
โ”‚ ...         โ”‚ ...                                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

# Get your public IP info
โžœ  monocle ip

monocle config

Show monocle configuration, data paths, and manage the database.

โžœ  monocle config --help
Show monocle configuration, data paths, and database management

Usage: monocle config [OPTIONS] [COMMAND]

Commands:
  db-refresh  Refresh data source(s)
  db-backup   Backup the database to a destination
  db-sources  List available data sources and their status
  help        Print this message or the help of the given subcommand(s)

Options:
      --debug            Print debug information
      --format <FORMAT>  Output format: table (default), markdown, json, json-pretty, json-line, psv
      --json             Output as JSON objects (shortcut for --format json-pretty)
  -v, --verbose          Show detailed information about all data files
  -h, --help             Print help

Examples:

# Show configuration and database status
โžœ  monocle config
Configuration:
  Config file: ~/.monocle.toml (not found, using defaults)
  Data directory: ~/.monocle

SQLite Database: ~/.monocle/monocle-data.sqlite3
  Size: 45.2 MB
  ASInfo: 120415 ASes
  AS2Rel: 1234567 relationships
  RPKI: 784188 ROAs, 388 ASPAs (updated 2 hours ago)
  Pfx2as: 1000000 prefixes

# Refresh all data sources
โžœ  monocle config db-refresh --all

# Refresh a specific source
โžœ  monocle config db-refresh asinfo
โžœ  monocle config db-refresh rpki

# Backup the database
โžœ  monocle config db-backup ~/monocle-backup.sqlite3

# List available data sources
โžœ  monocle config db-sources

monocle server

Start a WebSocket server for programmatic access to monocle functionality.

โžœ  monocle server --help
Start the WebSocket server

Usage: monocle server [OPTIONS]

Options:
  -a, --address <ADDRESS>  Bind address [default: 127.0.0.1]
  -p, --port <PORT>        Bind port [default: 8080]
  -h, --help               Print help

Endpoints:

  • WebSocket: ws://<address>:<port>/ws
  • Health check: http://<address>:<port>/health

Features:

  • JSON-RPC style request/response protocol
  • Streaming support with progress reporting for parse/search operations
  • Operation cancellation via op_id
  • DB-first policy: queries read from local SQLite cache

Available methods:

  • system.info, system.methods - Server introspection
  • time.parse - Time string parsing
  • ip.lookup, ip.public - IP information lookup
  • rpki.validate, rpki.roas, rpki.aspas - RPKI operations
  • as2rel.search, as2rel.relationship, as2rel.update - AS relationships
  • pfx2as.lookup - Prefix-to-ASN mapping
  • country.lookup - Country code/name lookup
  • inspect.query, inspect.refresh - Unified AS/prefix inspection
  • parse.start, parse.cancel - MRT file parsing (streaming)
  • search.start, search.cancel - BGP message search (streaming)
  • database.status, database.refresh - Database management

For detailed protocol specification, see src/server/README.md.

Example:

โžœ  monocle server
Starting WebSocket server on 127.0.0.1:8080
  WebSocket: ws://127.0.0.1:8080/ws
  Health: http://127.0.0.1:8080/health

โžœ  monocle server --address 0.0.0.0 --port 3000
Starting WebSocket server on 0.0.0.0:3000

Built with โค๏ธ by BGPKIT Team

https://bgpkit.com/logo.png

About

๐Ÿง See through all BGP data with a monocle.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5