-t 选项 :输出时不打印时间戳
- 没有使用 -t 选项时
[root@test ~]# tcpdump -i ens39 -c 1 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on ens39, link-type EN10MB (Ethernet), capture size 262144 bytes 15:36:50.707284 IP 192.168.146.6.netbios-ns > 192.168.146.255.netbios-ns: NBT UDP PACKET(137): QUERY; REQUEST; BROADCAST 1 packet captured 41 packets received by filter 0 packets dropped by kernel
- 使用了-t 选项时
[root@test ~]# tcpdump -i ens39 -c 1 -t tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on ens39, link-type EN10MB (Ethernet), capture size 262144 bytes IP test.bootpc > 192.168.146.254.bootps: BOOTP/DHCP, Request from 00:0c:29:bb:96:75 (oui Unknown), length 300 1 packet captured 2 packets received by filter 0 packets dropped by kernel
我们可以看到,使用了-t 选项之后,’15:36:50.707284‘消失了,这就是抓包的时间戳信息,至于为什么会精确到小数点后6位,这是因为tcpdump默认情况下就是按照微妙(microsecond)来计时的,其实,tcpdump还支持按纳秒计时呢,开启的方法是使用 --time-stamp-precision=nano 选项。
-v 选项:输出更详细的信息
加了 -v 选项之后,在原有输出内容的基础之上,我们还会看到tos值,ttl值,ID值,总长度,检验值。
没有使用 -v 选项输出的信息
[root@test ~]# tcpdump -i ens39 -c 1 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on ens39, link-type EN10MB (Ethernet), capture size 262144 bytes 15:59:56.419206 IP 192.168.146.6.mdns > 224.0.0.251.mdns: 0 A (QM)? wpad.local. (28) 1 packet captured 27 packets received by filter 0 packets dropped by kernel
使用 -v 选项输出的信息
[root@test ~]# tcpdump -i ens39 -c 1 -v tcpdump: listening on ens39, link-type EN10MB (Ethernet), capture size 262144 bytes 16:01:05.714829 IP (tos 0x0, ttl 1, id 55148, offset 0, flags [none], proto UDP (17), length 56) 192.168.146.6.mdns > 224.0.0.251.mdns: 0 A (QM)? wpad.local. (28) 1 packet captured 37 packets received by filter 0 packets dropped by kernel
-F选项:指定过滤表达式所在的文件
我们当初存储的过滤条件
[root@test ~]# cat filter.txt
port 22
使用-F选项来指定要读取的文件
[root@test ~]# tcpdump -i ens39 -c 1 -t -F filter.txt
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens39, link-type EN10MB (Ethernet), capture size 262144 bytes
IP 192.168.146.6.51804 > 192.168.146.131.ssh: Flags [F.], seq 2883813072, ack 608134279, win 4105, length 0
1 packet captured
3 packets received by filter
0 packets dropped by kernel