LoginSignup
5
4

More than 5 years have passed since last update.

tcpdumpを長時間取得したい

Posted at

やりたいこと:tcpdumpを長時間取得したい

IP 192.168.56.100の25番portのパケットキャプチャーを1日分取得したい。
※OSはRedHat7,キャプチャを取りたいNICはenp0s8

コマンドの準備

コマンドを実行する前に考慮したこと
- 出力されるファイルのサイズ
- サーバーと通信していなくても(ログアウトしても)、キャプチャが取得できること

どれくらいのファイルが出力されるかを/tmpで確認した。

/tmp
tcpdump -w test25 -i enp0s8 port 25 and host 192.168.56.100

コマンドを実行した5分後にctrl + Cを打鍵

ファイル(test25)の大きさを確認したが200KBほどだったため、単純計算で

200KB * 12 * 24 = 57.6MB

ファイルサイズは問題ない。

コマンド実行

/tmp
nohup tcpdump -w tcpdump25 -i enp0s8 port 25 and host 192.168.56.100 &

コマンドの説明

  • nohup
    サーバーからログアウトしてもプロセスが落ちない(job)

  • -w tcpdump25
    パケットキャプチャをtcpdump25というファイルに出力する

  • -i enp0s8
    パケットキャプチャを取得するNICはenp0s8

  • tcpdump XXX &
    tcpdumpのプロセスをバックグラウンドで実行

コマンド実行後

特に必要な処理はない。
私の場合はexitして1日後にサーバーにログインして
ps aux でtcpdumpのプロセスが存在することを確認した。

コマンド(プロセス)終了方法

kill [PID]

確認

出力したファイルをWireSharkで確認した。

5
4
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
5
4