1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

便利な asn コマンドの使い方メモ

Last updated at Posted at 2022-05-27

asn コマンド

nitefood/asn: ASN / RPKI validity / BGP stats / IPv4v6 / Prefix / URL / ASPath / Organization / IP reputation / IP geolocation / IP fingerprinting / Network recon / lookup API server / Web traceroute server

ネットワークのトラブルシューティングをするのに、入れておくと非常に助かるコマンドです。

traceroute やら mtr やらが動作し、ネットワーク情報を一元的に取得できるので便利です。

% asn -help 

╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ASN / RPKI validity / BGP stats / IPv4v6 / Prefix / ASPath / Organization / IP reputation lookup tool │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯

VERSION:

  0.71.6 

USAGE:

  asn [OPTIONS] [TARGET] 
  asn [-v] -l [SERVER OPTIONS] 

OPTIONS: 

  -d    (detailed)
	Output detailed hop info during the AS path trace to the TARGET 
	(This option also enables RPKI validation/BGP hijacking detection for every hop) 

  -n    (no trace)
	Disable tracing the AS path to the TARGET 

  -s    (ASN Suggest)
	Lookup AS names and numbers matching TARGET 

  -o    (organization search)
	Force TARGET to be treated as an Organization Name 

  -h    (help)
	Show this help screen 

  -l    (lookup server)
	Launch the script in server mode. See SERVER OPTIONS below 

TARGET: 

  <AS Number>
	Lookup matching ASN and BGP announcements/neighbours data. 
	(Supports "as123" and "123" formats - case insensitive) 

  <IPv4/IPv6>
	Lookup matching route(4/6), IP reputation and ASN data 

  <Prefix>
	Lookup matching ASN data 

  <host.name.tld>
	Lookup matching IP, route and ASN data. Supports multiple IPs - e.g. DNS RR 

  <URL>
	Extract hostname/IP from the URL and lookup relative data. Supports any protocol prefix, non-standard ports and prepended credentials 

  <Organization Name>
	Search by company name and lookup network ranges exported by (or related to) the company 

SERVER OPTIONS: 

  BIND_ADDRESS
	IP address (v4/v6) to bind the listening server to (e.g. 'asn -l 0.0.0.0')
	Default value: 127.0.0.1 

  BIND_PORT
	TCP Port to bind the listening server to (e.g. 'asn -l 12345')
	Default value: 49200 

  BIND_ADDRESS BIND_PORT
	IP address and port to bind the listening server to (e.g. 'asn -l ::1 12345') 

  -v    (verbose)
	Enable verbose output and debug messages in server mode 

  --allow host[,host,...]
	Allow only given hosts to connect to the server 

  --allowfile file
	A file of hosts allowed to connect to the server 

  --deny host[,host,...]
	Deny given hosts from connecting to the server 

  --denyfile file
	A file of hosts denied from connecting to the server 

  -m, --max-conns <n>
	The maximum number of simultaneous connections accepted by the server. 100 is the default. 


  Note: Every option in server mode (after -l) is passed directly to the ncat listener. 
        Refer to man ncat for more details on the available commands. 
        Unless specified, the default IP:PORT values of 127.0.0.1:49200 will be used (e.g. 'asn -l') 

  Example server usage: 
	asn -l 
	  (starts server on default IP:PORT)
 
	asn -l 0.0.0.0 --allow 192.168.0.0/24,192.168.1.0/24,192.168.2.245 
	  (binds to all availables IPv4 interfaces on the default port, allowing only connections from the three specified subnets)
 
	asn -l :: 2222 --allow 2001:DB8::/32 
	  (binds to all availables IPv6 interfaces on port 2222, allowing only connections from the specified prefix)
 
	asn -v -l 0.0.0.0 --allowfile "~/goodips.txt" -m 5 
	  (verbose mode, bind to all IPv4 interfaces, use an allowfile with allowed addresses, accept a maximum of 5 concurrent connections)
 
  Bookmarklet configuration page: 
	please visit http://127.0.0.1:49200/asn_bookmarklet and follow the instructions. More documentation is available on github (link below). 


Project homepage: https://github.com/nitefood/asn

IP 情報

% sudo asn 1.1.1.1       

╭────────────────────────╮
│ ASN lookup for 1.1.1.1 │
╰────────────────────────╯
                                                                                                                                                                                                      
 1.1.1.1 ┌PTR one.one.one.one
         ├ASN 13335 (CLOUDFLARENET, US)
         ├ORG APNIC and Cloudflare DNS Resolver project
         ├NET 1.1.1.0/24 (APNIC-LABS)
         ├ABU helpdesk@apnic.net
         ├ROA ✓ VALID (1 ROA found)
         ├TYP  Anycast IP   Hosting/DC 
         ├GEO Santiago, Región Metropolitana de Santiago (CL)
         └REP ✓  KNOWN GOOD as "Cloudflare Public DNS" 


╭──────────────────╮
│ Trace to 1.1.1.1 │
╰──────────────────╯

 Hop IP Address                                                                                  Loss%      Ping avg     AS Information                                                               
  1. 192.168.1.1                                                                                    0%        4.8 ms    BOGON  rfc1918 (Private Space)                                                
  2. xxx.xxx.ap.nuro.jp (x.x.x.x)                                                    0%        4.7 ms   [AS2527] SO-NET Sony Network Communications Inc., JP                           
  3. 92.203.137.40                                                                                  0%       46.9 ms   [AS2527] SO-NET Sony Network Communications Inc., JP                           
  4. 110.232.156.165                                                                                0%      139.4 ms   [AS2527] SO-NET Sony Network Communications Inc., JP                           
  5. 202.213.194.20                                                                                 0%       73.1 ms   [AS2527] SO-NET Sony Network Communications Inc., JP                           
  6. 210.173.176.127                                                                                0%        7.6 ms    IXP  JPNAP Tokyo (JPNAP Tokyo)                                                
  7. 172.70.220.2                                                                                   0%        7.0 ms   [AS13335] CLOUDFLARENET, US                                                    
  8. one.one.one.one (1.1.1.1)                                                                      0%       48.1 ms   [AS13335] CLOUDFLARENET, US                                                    
                                                                                                                                                                                                      
Trace complete in 24 seconds.


╭────────────────────╮
│ AS path to 1.1.1.1 │
╰────────────────────╯

  2527   SO-NET Sony Network Communications Inc. (Local AS)
 ╭╯
 ╰ IXP   JPNAP Tokyo (JPNAP Tokyo)
 ╭╯
 ╰13335  CLOUDFLARENET
% asn -n 205.210.31.158

╭───────────────────────────────╮
│ ASN lookup for 205.210.31.158 │
╰───────────────────────────────╯
                                                                                                                                                                                                      
 205.210.31.158 ┌PTR -
                ├ASN 396982 (GOOGLE-CLOUD-PLATFORM, US)
                ├ORG Palo Alto Networks, Inc
                ├NET 205.210.31.0/24 (PAN-22)
                ├ABU gns-prod@paloaltonetworks.com
                ├ROA ✓ VALID (1 ROA found)
                ├TYP  Hosting/DC 
                ├GEO Santa Clara, California (US)
                └REP ✓  KNOWN GOOD as "Cortex Xpanse"   SEEN SCANNING 

ASN 情報

% asn 2527

╭─────────────────────╮
│ ASN lookup for 2527 │
╰─────────────────────╯

 AS Number     ──> 2527
 AS Name       ──> SO-NET Sony Network Communications Inc., JP
 Organization  ──> Sony Network Communications Inc.
 AS Reg. date  ──> 2019-06-28 18:24:03
 Peering @IXPs ──> BBIX Osaka • BBIX Tokyo • Equinix Tokyo • JPIX TOKYO • JPNAP Osaka • JPNAP Tokyo: Peering


╭───────────────────────────────────────────────────────────────────────────╮
│ BGP informations for AS2527 (SO-NET Sony Network Communications Inc., JP) │
╰───────────────────────────────────────────────────────────────────────────╯

 IPv4 Prefixes  ────> 318                                                                                                                                                                             
 IPv6 Prefixes  ────> 8
 BGP Neighbours ────> 15


╭───────────────────────────────────────────────────────────────────────────────╮
│ Peering informations for AS2527 (SO-NET Sony Network Communications Inc., JP) │
╰───────────────────────────────────────────────────────────────────────────────╯

──────────────── Upstream Peers ────────────────

 HURRICANE (6939)   TWGATE-AP Taiwan Internet Gateway (9505)   IIJ Internet Initiative Japan Inc. (2497)   KDDI KDDI CORPORATION (2516)  
 BTN-ASN (3491)   COLT (8220)   ACORUS (35280)   TRANSTELECOM (20485)  
 LEVEL3 (3356)  

─────────────── Downstream Peers ───────────────

 SONYTELECOM So-net Corporation (9600)   SSD Sony Global Solutions Inc. (9619)   TBS-NET Tokyo Broadcasting System Television (131930)   USEN-NET USEN CORPORATION (24278)  

─────────────── Uncertain  Peers ───────────────

 UNITAS (1828)   GSLNETWORKS-AS-AP GSL Networks Pty LTD (137409)  


╭──────────────────────────────────────────────────────────────────────────────────────────╮
│ Announced prefixes (aggregated) for AS2527 (SO-NET Sony Network Communications Inc., JP) │
╰──────────────────────────────────────────────────────────────────────────────────────────╯

───── IPv4 ─────

103.2.48.0/22
103.241.124.0/22
110.232.152.0/21
110.66.0.0/15
111.0.0.0/8
115.162.0.0/15
116.67.128.0/17
116.82.0.0/15
118.236.0.0/15
118.238.0.0/17
118.238.192.0/18
118.240.0.0/15
120.0.0.0/8
121.101.64.0/18
121.103.0.0/16
121.2.0.0/15
123.198.0.0/16
124.0.0.0/8
131.147.0.0/16
131.213.0.0/16
133.0.0.0/8
143.189.0.0/16
147.192.0.0/16
150.147.0.0/16
150.246.0.0/16
150.249.0.0/16
152.117.128.0/17
152.165.0.0/16
157.147.0.0/16
159.28.128.0/17
159.28.64.0/18
160.86.0.0/16
164.70.128.0/17
182.168.0.0/14
198.144.160.0/20
202.212.0.0/14
202.220.0.0/14
202.224.0.0/15
202.226.0.0/15
202.228.0.0/15
202.236.0.0/14
207.65.128.0/17
209.17.64.0/19
210.0.0.0/8
211.0.0.0/8
216.153.64.0/18
218.0.0.0/8
219.0.0.0/8
220.208.0.0/12
223.132.0.0/14
39.0.0.0/8
58.87.128.0/17
59.146.0.0/15
61.112.0.0/12
61.200.0.0/13
61.208.0.0/13
66.11.48.0/20
90.149.0.0/16
92.202.0.0/15

───── IPv6 ─────

2001:3b8::/32

HOSTNAME 情報

% asn -n www.cloudflare.com

╭───────────────────────────────────╮
│ ASN lookup for www.cloudflare.com │
╰───────────────────────────────────╯

- Resolving "www.cloudflare.com"...        4 IP addresses found:

                                                                                                                                                                                                      
        104.16.123.96 ┌PTR -
                      ├ASN 13335 (CLOUDFLARENET, US)
                      ├ORG Cloudflare, Inc.
                      ├NET 104.16.112.0/20 (CLOUDFLARENET)
                      ├ABU abuse@cloudflare.com
                      ├ROA ✓ VALID (1 ROA found)
                      ├TYP  Hosting/DC 
                      ├GEO New York City, New York (US)
                      └REP ✓  KNOWN GOOD as "Cloudflare CDN" 

                                                                                                                                                                                                      
        104.16.124.96 ┌PTR -
                      ├ASN 13335 (CLOUDFLARENET, US)
                      ├ORG Cloudflare, Inc.
                      ├NET 104.16.112.0/20 (CLOUDFLARENET)
                      ├ABU abuse@cloudflare.com
                      ├ROA ✓ VALID (1 ROA found)
                      ├TYP  Hosting/DC 
                      ├GEO New York City, New York (US)
                      └REP ✓  KNOWN GOOD as "Cloudflare CDN" 

                                                                                                                                                                                                      
 2606:4700::6810:7c60 ┌PTR -
                      ├ASN 13335 (CLOUDFLARENET, US)
                      ├ORG Cloudflare, Inc. / Cloudflare, Inc.
                      ├NET 2606:4700::/44 (CLOUDFLARENET)
                      ├ABU abuse@cloudflare.com
                      ├ROA ✓ VALID (1 ROA found)
                      ├TYP  Hosting/DC 
                      ├GEO London, Westminster (GB)
                      └REP ✓ NONE

                                                                                                                                                                                                      
 2606:4700::6810:7b60 ┌PTR -
                      ├ASN 13335 (CLOUDFLARENET, US)
                      ├ORG Cloudflare, Inc. / Cloudflare, Inc.
                      ├NET 2606:4700::/44 (CLOUDFLARENET)
                      ├ABU abuse@cloudflare.com
                      ├ROA ✓ VALID (1 ROA found)
                      ├TYP  Hosting/DC 
                      ├GEO London, Westminster (GB)
                      └REP ✓ NONE

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?