@@ -24,6 +24,7 @@ See through all Border Gateway Protocol (BGP) data with a monocle.
2424 - [ ` monocle inspect ` ] ( #monocle-inspect )
2525 - [ ` monocle country ` ] ( #monocle-country )
2626 - [ ` monocle as2rel ` ] ( #monocle-as2rel )
27+ - [ ` monocle pfx2as ` ] ( #monocle-pfx2as )
2728 - [ ` monocle rpki ` ] ( #monocle-rpki )
2829 - [ ` monocle rpki validate ` ] ( #monocle-rpki-validate )
2930 - [ ` monocle rpki roas ` ] ( #monocle-rpki-roas )
@@ -186,12 +187,13 @@ Subcommands:
186187- ` parse ` : parse individual MRT files
187188- ` search ` : search for matching messages from all available public MRT files
188189- ` server ` : start a WebSocket server for programmatic access
189- - ` inspect ` : unified AS and prefix information lookup (replaces ` whois ` and ` pfx2as ` )
190+ - ` inspect ` : unified AS and prefix information lookup
190191- ` country ` : utility to look up country name and code
191192- ` time ` : utility to convert time between unix timestamp and RFC3339 string
193+ - ` as2rel ` : AS-level relationship lookup between ASNs
194+ - ` pfx2as ` : prefix-to-ASN mapping lookup with RPKI validation
192195- ` rpki ` : RPKI validation and ROA/ASPA listing
193196- ` ip ` : IP information lookup
194- - ` as2rel ` : AS-level relationship lookup between ASNs
195197- ` config ` : configuration display and database management (refresh, backup, sources)
196198
197199### Global Options
@@ -583,22 +585,29 @@ Look up AS-level relationships between ASNs using BGPKIT's AS relationship data.
583585➜ monocle as2rel --help
584586AS-level relationship lookup between ASNs
585587
586- Usage: monocle as2rel [OPTIONS] <ASN1> [ASN2]
588+ Usage: monocle as2rel [OPTIONS] <ASNS>...
587589
588590Arguments:
589- <ASN1> First ASN to look up
590- [ASN2] Second ASN (optional, shows all relationships for ASN1 if omitted)
591+ <ASNS>... One or more ASNs to query relationships for
592+ - Single ASN: shows all relationships for that ASN
593+ - Two ASNs: shows the relationship between them
594+ - Multiple ASNs: shows relationships for all pairs (asn1 < asn2)
591595
592596Options:
593- --debug Print debug information
594- --format <FORMAT> Output format: table (default), markdown, json, json-pretty, json-line, psv
595- --json Output as JSON objects (shortcut for --format json-pretty)
596- --update Force update the local database
597- --no-explain Hide the explanation text in table output
598- --sort-by-asn Sort results by ASN2 ascending (default: sort by connected % descending)
599- --show-name Show organization name for ASN2 (truncated to 20 chars)
600- --show-full-name Show full organization name without truncation
601- -h, --help Print help
597+ --debug Print debug information
598+ --format <FORMAT> Output format: table (default), markdown, json, json-pretty, json-line, psv
599+ --json Output as JSON objects (shortcut for --format json-pretty)
600+ --update Force update the local database
601+ --no-explain Hide the explanation text in table output
602+ --sort-by-asn Sort results by ASN2 ascending (default: sort by connected % descending)
603+ --show-name Show organization name for ASN2 (truncated to 20 chars)
604+ --show-full-name Show full organization name without truncation
605+ --min-visibility <PCT> Minimum visibility percentage (0-100) to include in results
606+ --single-homed Only show ASNs that are single-homed to the queried ASN
607+ --is-upstream Only show relationships where the queried ASN is an upstream (provider)
608+ --is-downstream Only show relationships where the queried ASN is a downstream (customer)
609+ --is-peer Only show peer relationships
610+ -h, --help Print help
602611```
603612
604613Output columns:
@@ -611,14 +620,128 @@ Output columns:
611620Examples:
612621
613622``` text
623+ # Look up relationship between two ASNs
614624➜ monocle as2rel 13335 174
615625┌───────┬──────┬───────────┬───────┬─────────────┬─────────────┐
616626│ asn1 │ asn2 │ connected │ peer │ as1_upstream│ as2_upstream│
617627├───────┼──────┼───────────┼───────┼─────────────┼─────────────┤
618628│ 13335 │ 174 │ 95.2% │ 85.1% │ 2.3% │ 7.8% │
619629└───────┴──────┴───────────┴───────┴─────────────┴─────────────┘
620630
631+ # Show all relationships for an ASN with names
621632➜ monocle as2rel 13335 --show-name | head -10
633+
634+ # Find ASNs that are single-homed to AS2914 (NTT)
635+ ➜ monocle as2rel 2914 --single-homed --show-name
636+
637+ # Find single-homed ASNs with at least 10% visibility
638+ ➜ monocle as2rel 2914 --single-homed --min-visibility 10
639+
640+ # Show only downstream customers of an ASN
641+ ➜ monocle as2rel 2914 --is-upstream --show-name
642+
643+ # Show only upstream providers of an ASN
644+ ➜ monocle as2rel 13335 --is-downstream --show-name
645+
646+ # Show relationships among multiple ASNs (all pairs)
647+ ➜ monocle as2rel 174 2914 3356 --show-name
648+ ```
649+
650+ ### ` monocle pfx2as `
651+
652+ Look up prefix-to-ASN mappings. Query by prefix to find origin ASNs, or by ASN to find announced prefixes.
653+ Results include RPKI validation status for each prefix-ASN pair.
654+
655+ ``` text
656+ ➜ monocle pfx2as --help
657+ Prefix-to-ASN mapping lookup
658+
659+ Query by prefix to find origin ASNs, or by ASN to find announced prefixes.
660+ Includes RPKI validation status for each prefix-ASN pair.
661+
662+ Usage: monocle pfx2as [OPTIONS] <QUERY>
663+
664+ Arguments:
665+ <QUERY> Query: an IP prefix (e.g., 1.1.1.0/24) or ASN (e.g., 13335, AS13335)
666+
667+ Options:
668+ -u, --update Force update the local pfx2as database
669+ --include-sub Include sub-prefixes (more specific) in results when querying by prefix
670+ --include-super Include super-prefixes (less specific) in results when querying by prefix
671+ --show-name Show AS name for each origin ASN
672+ --show-full-name Show full AS name without truncation (default truncates to 20 chars)
673+ -l, --limit <N> Limit the number of results (default: no limit)
674+ --debug Print debug information
675+ --format <FORMAT> Output format: table (default), markdown, json, json-pretty, json-line, psv
676+ --json Output as JSON objects (shortcut for --format json-pretty)
677+ -h, --help Print help
678+ ```
679+
680+ Examples:
681+
682+ ``` text
683+ # Look up a prefix - shows origin ASN and RPKI validation status
684+ ➜ monocle pfx2as 1.1.1.0/24
685+ ╭────────────┬────────────┬───────╮
686+ │ prefix │ origin_asn │ rpki │
687+ ├────────────┼────────────┼───────┤
688+ │ 1.1.1.0/24 │ 13335 │ valid │
689+ ╰────────────┴────────────┴───────╯
690+
691+ # Look up with AS name
692+ ➜ monocle pfx2as 1.1.1.0/24 --show-name
693+ ╭────────────┬────────────┬───────────────┬───────╮
694+ │ prefix │ origin_asn │ as_name │ rpki │
695+ ├────────────┼────────────┼───────────────┼───────┤
696+ │ 1.1.1.0/24 │ 13335 │ CLOUDFLARENET │ valid │
697+ ╰────────────┴────────────┴───────────────┴───────╯
698+
699+ # Look up by ASN - shows all prefixes announced by the ASN
700+ ➜ monocle pfx2as 13335 --limit 5 --show-name
701+ ╭─────────────────────┬────────────┬───────────────┬───────────╮
702+ │ prefix │ origin_asn │ as_name │ rpki │
703+ ├─────────────────────┼────────────┼───────────────┼───────────┤
704+ │ 172.69.7.0/24 │ 13335 │ CLOUDFLARENET │ valid │
705+ │ 2606:4700:839a::/48 │ 13335 │ CLOUDFLARENET │ valid │
706+ │ 8.36.218.0/24 │ 13335 │ CLOUDFLARENET │ not_found │
707+ │ 2400:cb00:b8e6::/48 │ 13335 │ CLOUDFLARENET │ valid │
708+ │ 172.68.134.0/24 │ 13335 │ CLOUDFLARENET │ valid │
709+ ╰─────────────────────┴────────────┴───────────────┴───────────╯
710+
711+ # Include sub-prefixes (more specific prefixes)
712+ ➜ monocle pfx2as 8.8.0.0/16 --include-sub --limit 5 --show-name
713+ ╭──────────────┬────────────┬────────────┬───────────╮
714+ │ prefix │ origin_asn │ as_name │ rpki │
715+ ├──────────────┼────────────┼────────────┼───────────┤
716+ │ 8.0.0.0/12 │ 3356 │ LEVEL3 │ not_found │
717+ │ 8.8.8.0/24 │ 15169 │ GOOGLE │ valid │
718+ │ 8.8.249.0/24 │ 989 │ ANAXA3-ASN │ valid │
719+ │ 8.8.216.0/24 │ 13781 │ ENERGYNET │ valid │
720+ │ 8.8.64.0/24 │ 3356 │ LEVEL3 │ not_found │
721+ ╰──────────────┴────────────┴────────────┴───────────╯
722+
723+ # Include super-prefixes (less specific prefixes)
724+ ➜ monocle pfx2as 1.1.1.0/24 --include-super
725+
726+ # JSON output
727+ ➜ monocle pfx2as 13335 --limit 3 --json
728+ [
729+ {
730+ "prefix": "172.69.7.0/24",
731+ "origin_asn": 13335,
732+ "rpki": "valid"
733+ },
734+ {
735+ "prefix": "2606:4700:839a::/48",
736+ "origin_asn": 13335,
737+ "rpki": "valid"
738+ },
739+ {
740+ "prefix": "8.36.218.0/24",
741+ "origin_asn": 13335,
742+ "rpki": "not_found"
743+ }
744+ ]
622745```
623746
624747### ` monocle rpki `
0 commit comments