tcpdump の -w オプションってずっと動かしてたら pcap ファイルが無限に大きくなるよなぁ、などと思いつつ man ページをつらつらと眺めていたら、こんなオプションが。

-C
Before writing a raw packet to a savefile, check whether the file is currently larger than file_size and, if so, close the current savefile and open a new one. Savefiles after the first savefile will have the name specified with the -w flag, with a number after it, starting at 1 and continuing upward. The units of file_size are millions of bytes (1,000,000 bytes, not 1,048,576 bytes).

出力した pcap ファイルのサイズが指定値を超えたら別のファイルに書くようになるわけですね。時間で切り替え(ログファイルを daily で rotate するように)できないし、シグナルを送って強制的に切り替えさせることもできないのが残念ですが。

とりあえず仕事ではこれを使ってみるかな…

Trackback

no comment untill now

Add your comment now