サンプル集 |
■VC ■C# ■Java ■BorlandC ■LinuxC ■MS-DOS ■bash ■Excel VBA ■VBScript ■PHP ■HTML ■perl ■iPhone ■Android ■Lua ■other |
Linuxコマンド |
用語集 |
debian メモ |
apache2 メモ |
MySQL メモ |
Oracle メモ |
HOME |
tcpdumpを使ってみます。
OS | Debian 7.6 Linux obsax3 3.2.54 #1 SMP Tue Jun 17 12:25:14 JST 2014 armv7l GNU/Linux |
---|
インストール
root@obsax3:~# aptitude install tcpdump
インストールできない場合
root@obsax3:~# aptitude install tcpdump
以下の新規パッケージがインストールされます:
tcpdump
更新: 0 個、新規インストール: 1 個、削除: 0 個、保留: 1 個。
391 k バイトのアーカイブを取得する必要があります。展開後に 751 k バイト
のディスク領域が新たに消費されます。
Err http://ftp.xxx.co.jp/pub/debian/ wheezy/main tcpdump armhf 4.3.0-1
404 Not Found
0% [Working]E: http://ftp.xxx.co.jp/pub/debian/pool/main/t/tcpdump/tcpd
ump_4.3.0-1_armhf.deb を取得できませんでした: 404 Not Found
以下の新規パッケージがインストールされます:
tcpdump
更新: 0 個、新規インストール: 1 個、削除: 0 個、保留: 1 個。
391 k バイトのアーカイブを取得する必要があります。展開後に 751 k バイト
のディスク領域が新たに消費されます。
Err http://ftp.xxx.co.jp/pub/debian/ wheezy/main tcpdump armhf 4.3.0-1
404 Not Found
0% [Working]E: http://ftp.xxx.co.jp/pub/debian/pool/main/t/tcpdump/tcpd
ump_4.3.0-1_armhf.deb を取得できませんでした: 404 Not Found
どうやらDebianが7.8になっていないとだめなようです。 OSをアップグレードするのは少し怖いので他に良い方法が無いか考えてみます。
Debian 7.8の環境でdebファイルをダウンロードして7.6にインストールしてはどうかと考えました。 まずはDebian 7.8でdebファイルをダウンロードします。
root@obsax3:~# aptitude download tcpdump
取得: 1 http://ftp.plathome.co.jp/pub/debian/ wheezy/main tcpdump armhf
4.3.0-1+deb7u1 [391 kB]
Fetched 391 kB in 0秒 (899 kB/s)
root@obsax3:~# ls -l
-rw-r--r-- 1 root root 391476 12月 4 04:07 tcpdump_4.3.0-1+deb7u1_a
rmhf.deb
取得: 1 http://ftp.plathome.co.jp/pub/debian/ wheezy/main tcpdump armhf
4.3.0-1+deb7u1 [391 kB]
Fetched 391 kB in 0秒 (899 kB/s)
root@obsax3:~# ls -l
-rw-r--r-- 1 root root 391476 12月 4 04:07 tcpdump_4.3.0-1+deb7u1_a
rmhf.deb
ダウンロードしたファイルをDebian 7.6のPCへコピーしてインストールします。
root@obsax3:~# dpkg -i tcpdump_4.3.0-1+deb7u1_armhf.deb
以前に未選択のパッケージ tcpdump を選択しています。
(データベースを読み込んでいます ... 現在 19059 個のファイルとディレクト
リがインストールされています。)
(tcpdump_4.3.0-1+deb7u1_armhf.deb から) tcpdump を展開しています...
tcpdump (4.3.0-1+deb7u1) を設定しています ...
man-db のトリガを処理しています ...
以前に未選択のパッケージ tcpdump を選択しています。
(データベースを読み込んでいます ... 現在 19059 個のファイルとディレクト
リがインストールされています。)
(tcpdump_4.3.0-1+deb7u1_armhf.deb から) tcpdump を展開しています...
tcpdump (4.3.0-1+deb7u1) を設定しています ...
man-db のトリガを処理しています ...
インストールできたようです。
-hオプションをつけて実行し、オプションで何が使えるか確認します。
root@obsax3:~# tcpdump -h
tcpdump version 4.3.0
libpcap version 1.3.0
Usage: tcpdump [-aAbdDefhHIJKlLnNOpqRStuUvxX] [ -B size ] [ -c count ]
[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
[ -i interface ] [ -j tstamptype ] [ -M secret ]
[ -r file ] [ -s snaplen ] [ -T type ] [ -w file ]
[ -W filecount ] [ -y datalinktype ] [ -z command ]
[ -Z user ] [ expression ]
tcpdump version 4.3.0
libpcap version 1.3.0
Usage: tcpdump [-aAbdDefhHIJKlLnNOpqRStuUvxX] [ -B size ] [ -c count ]
[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
[ -i interface ] [ -j tstamptype ] [ -M secret ]
[ -r file ] [ -s snaplen ] [ -T type ] [ -w file ]
[ -W filecount ] [ -y datalinktype ] [ -z command ]
[ -Z user ] [ expression ]
使えそうですね。
aptitudeコマンドでダウンロードするパッケージの一覧を取得先が/etc/apt/sources.listファイルに書かれています。 こちらにDebian 7.6用のtcpdumpがあるURLを記載すればダウンロードできそうですが適当なサイトが見つかりませんでした。
実行
UPDのポート5060をダンプしdump20150401.pcapというファイルに出力してみます。
root@obsax3:~# tcpdump -C 1 -i any -s 0 -w dump20150401.pcap udp port 5
060 &
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture
size 65535 bytes
060 &
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture
size 65535 bytes
-i anyは全てのNICをキャプチャという指定で、-C 1 は1M毎にファイルを作成するという指定です。
実行すると、実行中はプロンプトに戻らなくなるので最後に & をつけて突き放しで実行するといい感じですね。
Copyright (C) 2015 ymlib.com