Linux tcpdump wオプションで出力ファイルが空データ

Linux tcpdump wオプションで出力ファイルが空データだったので、調べてみました。

 

参考になった情報がこちら。

 

このオプションを使用してキャプチャをファイルにRed Hat Enterprise Linux Server release 6.5保存すると、結果のファイルは空になります。tcpdump-w

 

[root@plop ~]# tcpdump -n -w tcpdump.cap
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
^C217 packets captured
217 packets received by filter
0 packets dropped by kernel
[root@plop ~]# cat tcpdump.cap
[root@plop ~]# ll tcpdump.cap
-rw-r-----. 1 root root 0 Aug 25 14:13 tcpdump.cap
[root@plop ~]#


>また、とを使用してコマンドの出力をリダイレクトしようとしました&>が、常に空のファイルが得られます...

その理由は何でしょうか?

注意:

ファイルにリダイレクトしない場合、ターミナルで正しい出力(多くのパケット)が表示されます。
同じことを実行しましたがthsark、期待どおりに機能しました(出力ファイルは正しかったです)
のバージョンtcpdumptcpdump version 4.1-PRE-CVS_2012_02_01
libpcapのバージョンはlibpcap version 1.4.0
オプションで試してみましたが-U、問題は解決しませんでした。

 

 

オプションを追加してみてください-U。

マニュアルページから:

   -U
   --packet-buffered
          If  the  -w option is not specified, make the printed packet output ``packet-buffered''; i.e., as the description of the contents of each packet is printed, it will be written to the standard
          output, rather than, when not writing to a terminal, being written only when the output buffer fills.

      If the -w option is specified, make the saved raw packet output ``packet-buffered''; i.e., as each packet is saved, it will be written to the output file, rather than being written only  when
      the output buffer fills.

      The -U flag will not be supported if tcpdump was built with an older version of

 

私のケースで参考になったのがIF指定でした。

 

インターフェイスを指定してみてください。例:tcpdump -ni eth0

 

権限や、その他理由で、うまく動作しないケースがあるかと思いますが、一例として参考までに。

 

pcap - Why is tcpdump output file empty? - Unix & Linux Stack Exchange