本文主要介绍了如何使用tcpdump
来捕获和查看网络数据包。
7. 选项 -r
如果你已经走到了这一步并且写入了一个.pcap
文件,你知道你不能使用简单的文本编辑器来读取文件内容。因此,你应该使用-r file.pcap
选项。它读取现有的捕获文件并将其打印为输出。
# tcpdump -i any port 8080 -w 8080.pcap -v
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
^C14 packets captured
28 packets received by filter
0 packets dropped by kernel
# tcpdump -r 8080.pcap
reading from file 8080.pcap, link-type LINUX_SLL (Linux cooked)
15:01:09.515750 IP 10.10.10.11.51710 > 10.10.10.11.webcache: Flags [S], seq 4077166376, win 65495, options [mss 65495,sackOK,TS val 1908517405 ecr 0,nop,wscale 7], length 0
15:01:09.515760 IP 10.10.10.11.webcache > 10.10.10.11.51710: Flags [S.], seq 2501983880, ack 4077166377, win 65483, options [mss 65495,sackOK,TS val 1908517405 ecr 1908517405,nop,wscale 7], length 0
15:01:09.51