FreeBSDに係わる構築や維持など

ASLookup

tracerouteにASNの表示オプション

これでntraceroute(ports collection)やprtraceroute(IRRToolSet)を使わなくてもすむようになるかも。

%uname -a
FreeBSD bsd.local 7.1-RELEASE-p1 FreeBSD 7.1-RELEASE-p1 #0: Thu Jan  8 14:03:38 JST 2009                             tiesto@bsd.local:/usr/obj/usr/src/sys/GENERIC  i386

%traceroute -h
Version 1.4a12+FreeBSD
Usage: traceroute [-adDeFInrSvx] [-f first_ttl] [-g gateway] [-i iface]
        [-m max_ttl] [-p port] [-P proto] [-q nqueries] [-s src_addr]
        [-t tos] [-w waittime] [-A as_server] [-z pausemsecs] host [packetlen]

%traceroute -a ftp2.ru.FreeBSD.org
traceroute to mirror.macomnet.net (195.128.64.25), 64 hops max, 40 byte packets
 1  [AS64520]  (192.168.11.1)  0.358 ms  0.260 ms  0.213 ms
 2  [AS4713] 122.28.23.99 (122.28.23.99)  4.339 ms  4.677 ms  3.476 ms
 3  [AS4713] 122.28.23.97 (122.28.23.97)  4.106 ms  4.650 ms  5.352 ms
 4  [AS4713] 122.1.164.201 (122.1.164.201)  7.972 ms  6.499 ms  6.724 ms
 5  [AS4713] 60.37.55.165 (60.37.55.165)  4.349 ms  4.928 ms  5.103 ms
 6  [AS4713] 60.37.54.213 (60.37.54.213)  4.977 ms  4.409 ms  5.112 ms
 7  [AS4713] 122.1.245.9 (122.1.245.9)  11.585 ms  5.300 ms  8.099 ms
 8  [AS4713] 122.1.245.18 (122.1.245.18)  10.599 ms  10.307 ms  10.345 ms
 9  [AS4713] 125.170.96.54 (125.170.96.54)  12.224 ms  12.675 ms  11.848 ms
10  [AS4713] 210.163.253.38 (210.163.253.38)  13.099 ms  12.799 ms  12.850 ms
11  [AS4713] 60.37.18.38 (60.37.18.38)  12.967 ms  12.800 ms  12.595 ms
12  [AS2914] ae-0-1.a20.osakjp01.jp.ra.gin.ntt.net (61.200.82.145)  13.086 ms  13.352 ms  13.098 ms
13  [AS2914] xe-9-3.a14.tokyjp01.jp.ra.gin.ntt.net (61.213.162.201)  11.971 ms  13.428 ms
    [AS2914] xe-7-0-0.a20.tokyjp01.jp.ra.gin.ntt.net (61.213.169.137)  15.470 ms
14  [AS2914] as-2.r22.londen03.uk.bb.gin.ntt.net (129.250.17.66)  263.942 ms  264.270 ms
    [AS2914] xe-4-0-0.a21.tokyjp01.jp.ra.gin.ntt.net (61.120.145.189)  12.594 ms
15  [AS2914] as-1.r22.amstnl02.nl.bb.gin.ntt.net (129.250.17.62)  301.617 ms  241.208 ms  241.713 ms
16  * * [AS2914] ae-1.r23.amstnl02.nl.bb.gin.ntt.net (129.250.4.222)  239.981 ms
17  [AS702] so-1-0-0.XR2.FFT1.ALTER.NET (146.188.15.198)  243.477 ms * *
18  * * *
19  [AS702] so-0-0-0.XR1.FFT1.ALTER.NET (146.188.15.186)  240.801 ms  243.010 ms  245.894 ms
20  [AS702] pos0-0.GW9.FFT4.ALTER.NET (149.227.48.26)  239.831 ms
    [AS8470] mirror.macomnet.net (195.128.64.25)  283.939 ms  286.889 ms

%geoiplookup ftp2.ru.FreeBSD.org
GeoIP Country Edition: RU, Russian Federation

MFC r176428:

	Add AS lookup functionality. On each hop we query a whois server to
	find the corresponding AS for that IP (-a switch).
	We can also choose a different whois server with the -A switch. The
	default is whois.radb.net.

	Obtained from:	       NetBSD

AS Number Lookup Utilityインストール

ASLookupは、指定されるASNをキーにRADBのAS Objectを検索し、そのDescription を表示するものです。

■複数のASNを一気に指定できる。
■Ciscoルータでshow ip bgp した結果がそのまま利用できる。
■ARIN、JPNIC、APNICのwhois dabaseも検索可能です。
■IPアドレスからASNの検索が可能です。

1. aslookupのインストール

# wget http://www.bugest.net/software/aslookup/aslookup-beta0.13c.tar.gz
# tar -xzvf aslookup-beta0.13c.tar.gz
# cd aslookup-beta0.13c

# vi Makefile
#CFLAGS  = -DRALOCAL -DJPNICDB -DAPNICDB -g -O
CFLAGS  = -DJPNICDB -DAPNICDB -g -O
INCDIR = -I./

# vi aslookup.c
#ifdef RALOCAL
#define RADB "localhost"
#define WHOIS 43
#endif /* _ifedef RALOCAL */
#ifndef RALOCAL
#define RADB "whois.ra.net"
#define WHOIS 43
#endif /* _ifndef RALOCAL */

#ifdef LOG
#define LOGFILE "/var/log/aslookup.log"
#endif /* _ifdef LOG */
# make
gcc -c -DJPNICDB -DAPNICDB -g -O aslookup.c
Linking ...
gcc -DJPNICDB -DAPNICDB -g -O -I./  -o aslookup aslookup.o
done
# make install
Installing aslookup ...
/usr/bin/install -c -m 4555 -o root -g bin aslookup /usr/local/bin/
done

2. IPアドレスからASNを検索

# aslookup -r 195.117.69.196
Target Address : 195.117.69.196
   195.117.0.0/16:  AS5617:Polish Telecom's commercial IP network

3. ASNを指定しAS ObjectのDescriptionを検索

# aslookup 2914 4713 2516 2497 4716 4691 2527 2521 2915 4682 4694 4722 4725 17676 10007
  AS2914:NTT Communications Global IP Network
  AS4713:NTT-OCNET
  AS2516:KDDI Corporation
  AS2497:IIJNET
  AS4716:POWEREDCOM, Shinagawa East One Tower,
  AS4691:DTI aut-num object
  AS2527:JPNIC
  AS2521:Japan Telecom IDC Inc.
  AS2915:SPIN-NET
  AS4682:JENS Corporation
  AS4694:Japan Telecom IDC Inc.
  AS4722:Japan Telecom Co.,Ltd.  World Stream IP Service.
  AS4725:Japan Telecom Co.,Ltd. Open Data Network.
  AS17676:BB Technology Corporation.
  AS10007:Japan Network Information Center

AS Number Lookup Utility