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

Archive for 5月, 2006

isoイメージのマウント

# mdconfig -a -t vnode -f /target/6.1-RELEASE-i386-disc1.iso
md0
# mount -t cd9660 -r /dev/md0 /mnt
# umount /mnt
# mdconfig -d -u 0

md5、sha256の使用方法

$ ls
6.1-RELEASE-i386-bootonly.iso   CHECKSUM.MD5
6.1-RELEASE-i386-disc1.iso      CHECKSUM.SHA256
6.1-RELEASE-i386-disc2.iso
$ md5 6.1-RELEASE-i386-disc1.iso
MD5 (6.1-RELEASE-i386-disc1.iso) = cf1ce4ba48d664ce3977108a18ced6b8
$ cat CHECKSUM.MD5
MD5 (6.1-RELEASE-i386-bootonly.iso) = 11bb7fb4d2a781238008945f6bf65a4e
MD5 (6.1-RELEASE-i386-disc1.iso) = cf1ce4ba48d664ce3977108a18ced6b8
MD5 (6.1-RELEASE-i386-disc2.iso) = bc0f4a32a64e00c7cbfb839e6d5772f3
$ sha256 6.1-RELEASE-i386-disc1.iso
SHA256 (6.1-RELEASE-i386-disc1.iso) = cbc6f9389c85f3130baff5270316ece18d5e324e82f8aa167c61ab49174dd4d1
$ cat CHECKSUM.SHA256
SHA256 (6.1-RELEASE-i386-bootonly.iso) = cb7ad11198358e2123dc139d7fbab26727524e973c6c02906cc6aca944b064c9
SHA256 (6.1-RELEASE-i386-disc1.iso) = cbc6f9389c85f3130baff5270316ece18d5e324e82f8aa167c61ab49174dd4d1
SHA256 (6.1-RELEASE-i386-disc2.iso) = 7c3a056d18be9e2dccf1f4e7dba22a4760d6288165eb87fe9894abc8c7741ffb

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

IRRToolSet 4.7.3_1インストール

IRRToolSetインストール

# cd /usr/ports/net-mgmt/irrtoolset
# make clean
===>  Cleaning for gmake-3.80_2
===>  Cleaning for gcc-2.95.3_2
===>  Cleaning for bison-1.75_2,1
===>  Cleaning for tk-8.3.5_5
===>  Cleaning for gettext-0.14.5_2
===>  Cleaning for m4-1.4.4
===>  Cleaning for tcl-8.3.5_5
===>  Cleaning for xorg-libraries-6.9.0
===>  Cleaning for libtool-1.5.22_2
===>  Cleaning for libiconv-1.9.2_2
===>  Cleaning for imake-6.9.0
===>  Cleaning for libdrm-2.0.1_1
===>  Cleaning for freetype2-2.1.10_3
===>  Cleaning for fontconfig-2.3.2_5,1
===>  Cleaning for perl-5.8.8
===>  Cleaning for pkgconfig-0.20_2
===>  Cleaning for expat-2.0.0_1
===>  Cleaning for irrtoolset-4.7.3_1

# make install
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/bin/roe
/usr/local/bin/peval
/usr/local/bin/prtraceroute
/usr/local/bin/aoe
/usr/local/bin/prpath
/usr/local/bin/RtConfig
/usr/local/bin/rpslcheck
/usr/local/bin/CIDRAdvisor

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

      For more information, and contact details about the security
      status of this software, see the following webpage:

http://www.isc.org/index.pl?/sw/IRRToolSet/

print the route and policy information packets take to a network host

各hopのASNを表示する
# prtraceroute www.freebsd.org
prtraceroute to www.freebsd.org (216.136.204.117), 30 hops max, 12 byte packets
 1  [AS568] modemnv3-885f2e (192.168.1.1)  1.257 ms  1.282 ms  1.342 ms
 2  [AS4713] 60.42.255.5 (60.42.255.5)  51.694 ms  53.736 ms  50.07 ms
 3  [AS4713] 218.47.158.241 (218.47.158.241)  56.557 ms  55.955 ms  53.934 ms
 4  [AS4713] 218.43.251.249 (218.43.251.249)  64.066 ms  63.751 ms  51.689 ms
 5  [AS4713] 221.184.4.5 (221.184.4.5)  62.31 ms  55.749 ms  62.304 ms
 6  [AS4713] 210.254.188.149 (210.254.188.149)  51.938 ms  54.33 ms  51.581 ms
 7  [AS4713] 210.254.188.166 (210.254.188.166)  56.185 ms  54.191 ms  53.693 ms
 8  [AS2914] 61.213.161.217 (61.213.161.217)  52.109 ms  53.564 ms  52.214 ms
 9  [AS2914] xe-2-1-0.r21.tokyjp01.jp.bb.gin.ntt.net (61.213.162.97)  53.665 ms  218.463 ms  53.828 ms
10  [AS2914] p64-2-1-0.r21.sttlwa01.us.bb.gin.ntt.net (129.250.4.185)  166.012 ms  165.868 ms  166.261 ms
11  [AS3549] so5-0-0-2488.ar2.SEA1.gblx.net (208.51.134.81)  358.276 ms  420.116 ms  349.72 ms
12  [AS3549] so5-0-0-2488M.ar2.PAO2.gblx.net (67.17.93.109)  459.819 ms  648.385 ms  433.563 ms
13  [AS3549] 208.51.74.22 (208.51.74.22)  318.578 ms  182.082 ms  354.289 ms
14  [AS26085] ge-3-0-0-p402.msr1.sc5.yahoo.com (216.115.107.5)  530.025 ms [AS26085] ge-2-0-0-p212.msr2.sc5.yahoo.com (216.115.107.25)  526.618 ms [AS26085] ge-2-0-0-p202.msr1.sc5.yahoo.com (216.115.107.1)  303.788 ms
15  [AS26085] ge-1-3.bas2.sc5.yahoo.com (66.163.161.70)  694.377 ms [AS26085] ge-6-7.bas2.sc5.yahoo.com (66.163.160.222)  547.674 ms [AS26085] ge-8-16.bas2.sc5.yahoo.com (66.163.160.214)  690.563 ms
16  [AS26085] www.freebsd.org (216.136.204.117)  158.62 ms  142.837 ms  157.877 ms

Path taken:
AS568 AS4713 AS2914 AS3549 AS26085

 16  AS26085 www.freebsd.org                     destination -> internal
 15  AS26085 ge-8-16.bas2.sc5.yahoo.com            internal -> internal
 14  AS26085 ge-2-0-0-p202.msr1.sc5.yahoo.com      internal -> export
 13  AS3549 208.51.74.22                         import: 2 -> internal
 12  AS3549 so5-0-0-2488M.ar2.PAO2.gblx.net       internal -> internal
 11  AS3549 so5-0-0-2488.ar2.SEA1.gblx.net        internal -> !export
 10  AS2914 p64-2-1-0.r21.sttlwa01.us.bb.gin.ntt.net  import: 2 -> internal
  9  AS2914 xe-2-1-0.r21.tokyjp01.jp.bb.gin.ntt.net   internal -> internal
  8  AS2914 61.213.161.217                        internal -> export
  7  AS4713 210.254.188.166                      import: 1 -> internal
  6  AS4713 210.254.188.149                       internal -> internal
  5  AS4713 221.184.4.5                           internal -> internal
  4  AS4713 218.43.251.249                        internal -> internal
  3  AS4713 218.47.158.241                        internal -> internal
  2  AS4713 60.42.255.5                           internal -> !export
  1  AS568 modemnv3-885f2e                      import: 2 -> internal
  0  AS568 tiesto                                internal -> source

IRRToolSet

GeoIP APIs

Perl CPAN経由

cpan> install Geo::IPfree
Running install for module Geo::IPfree
Running make for G/GM/GMPASSOS/Geo-IPfree-0.2.tar.gz
Fetching with LWP:
  ftp://ftp.kddilabs.jp/CPAN/authors/id/G/GM/GMPASSOS/Geo-IPfree-0.2.tar.gz
CPAN: Digest::MD5 loaded ok
Fetching with LWP:
  ftp://ftp.kddilabs.jp/CPAN/authors/id/G/GM/GMPASSOS/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/G/GM/GMPASSOS/Geo-IPfree-0.2.tar.gz ok
Scanning cache /root/.cpan/build for sizes
x Geo-IPfree-0.2/
x Geo-IPfree-0.2/benchmark/
x Geo-IPfree-0.2/benchmark/benchmark.pl
x Geo-IPfree-0.2/benchmark/benchmark2.pl
x Geo-IPfree-0.2/Changes
x Geo-IPfree-0.2/lib/
x Geo-IPfree-0.2/lib/Geo/
x Geo-IPfree-0.2/lib/Geo/ipct2txt.pl
x Geo-IPfree-0.2/lib/Geo/IPfree.pm
x Geo-IPfree-0.2/lib/Geo/ipscountry.dat
x Geo-IPfree-0.2/lib/Geo/txt2ipct.pl
x Geo-IPfree-0.2/Makefile.PL
x Geo-IPfree-0.2/MANIFEST
x Geo-IPfree-0.2/README
x Geo-IPfree-0.2/test.pl

  CPAN.pm: Going to build G/GM/GMPASSOS/Geo-IPfree-0.2.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Geo::IPfree
cp lib/Geo/IPfree.pm blib/lib/Geo/IPfree.pm
cp lib/Geo/ipscountry.dat blib/lib/Geo/ipscountry.dat
cp lib/Geo/ipct2txt.pl blib/lib/Geo/ipct2txt.pl
cp lib/Geo/txt2ipct.pl blib/lib/Geo/txt2ipct.pl
Manifying blib/man3/Geo::IPfree.3
  /usr/bin/make  -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/local/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
1..5
# Running under perl version 5.008008 for freebsd
# Current time local: Tue May 23 16:46:32 2006
# Current time GMT:   Tue May 23 07:46:32 2006
# Using Test.pm version 1.25
ok 1
ok 2
ok 3
ok 4
ok 5
  /usr/bin/make test -- OK
Running make install
Installing /usr/local/lib/perl5/site_perl/5.8.8/Geo/IPfree.pm
Installing /usr/local/lib/perl5/site_perl/5.8.8/Geo/ipscountry.dat
Installing /usr/local/lib/perl5/site_perl/5.8.8/Geo/ipct2txt.pl
Installing /usr/local/lib/perl5/site_perl/5.8.8/Geo/txt2ipct.pl
Installing /usr/local/lib/perl5/5.8.8/man/man3/Geo::IPfree.3
Writing /usr/local/lib/perl5/site_perl/5.8.8/mach/auto/Geo/IPfree/.packlist
FreeBSD: Registering installation in the package database
Appending installation info to /usr/local/lib/perl5/5.8.8/mach/perllocal.pod
  /usr/bin/make install  -- OK

portからインストール

# cd /usr/ports/net/GeoIP
# make
# make install

# geoiplookup -v
GEO-106FREE 20050701 Build 1 Copyright (c) 2005 MaxMind LLC All Rights Reserved

# cd /usr/local/share/GeoIP;ll
total 2592
-rw-r--r--  1 root  wheel  869092 May  3 14:06 GeoIP.dat
-rw-r--r--  1 root  wheel  832246 May 20 08:24 GeoIP20050901.dat
-rw-r--r--  1 root  wheel  869092 May  3 14:06 GeoIP20060503.dat

# cp -p GeoIP.dat GeoIP20050605.dat

ここで、新しいGeoIP.datと入れ替え。

# geoiplookup -v
GEO-106FREE 20060501 Build 1 Copyright (c) 2006 MaxMind LLC All Rights Reserved

# geoiplookup 83.131.191.164
GeoIP Country Edition: HR, Croatia

GeoLite Country Binary Format
MaxMind:http://www.maxmind.com/app/api