在使用 tcpdump 捕获流量时如何查看流量。
当我使用 -w 时,它不会在捕获过程中显示数据包。
sudo tcpdump -i enp2s0 -w test.pcap
tcpdump: listening on enp2s0, link-type EN10MB (Ethernet), capture size 262144 bytes
^C6 packets captured
7 packets received by filter
0 packets dropped by kernel
Run Code Online (Sandbox Code Playgroud)
所以经过一些实验后,如果如下:
sudo tcpdump -i enp2s0 -U -w - | tee test.pcap | tcpdump -r -
Run Code Online (Sandbox Code Playgroud)
-w -
: 写入标准输出。
-U
: 数据包到达后立即写入。不要等到缓冲区已满。
Tee
将写入文件,并tcpdump -r -
从标准输入读取数据包。