[root@hf-01 ~]# tcpdump -nn
tcpdump: packet printing is not supported for link type NFLOG: use -w
[root@hf-01 ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.74.129 netmask 255.255.255.0 broadcast 192.168.74.255
inet6 fe80::20c:29ff:feff:fe93 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:ff:fe:93 txqueuelen 1000 (Ethernet)
RX packets 11067 bytes 12250186 (11.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2631 bytes 312427 (305.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@hf-01 ~]# tcpdump -nn -i eno16777736
5204, ack 6605, win 159, length 180
06:27:41.186368 IP 192.168.74.129.22 > 192.168.74.1.49322: Flags [P.], seq 45955204:45955384, ack 6605, win 159, length 180
06:27:41.186422 IP 192.168.74.129.22 > 192.168.74.1.49322: Flags [P.], seq 45955384:45955564, ack 6605, win 159, length 180
等等等,运行后,会显示出很多的信息
按ctrl+c退出
[root@hf-01 ~]# tcpdump -nn -i eno16777736 port 22
4, length 0
06:52:04.034073 IP 192.168.74.129.22 > 192.168.74.1.49322: Flags [P.], seq 228004:228376, ack 1, win 159, length 372
06:52:04.034155 IP 192.168.74.129.22 > 192.168.74.1.49322: Flags [P.], seq 228376:228556, ack 1, win 159, length 180
06:52:04.034302 IP 192.168.74.1.49322 > 192.168.74.129.22: Flags [.], ack 228556, win 252, length 0
06:52:04.034387 IP 192.168.74.129.22 > 192.168.74.1.49322: Flags [P.], seq 228556:228832, ack 1, win 159, length 276
等等等,只截取了一部分
在这里复制另一个终端,并打开,跑vmstat 1命令
在当前终端查看,输入以下命令
[root@hf-01 ~]# tcpdump -nn -i eno16777736 -c 10 -w 1.cap
tcpdump: listening on eno16777736, link-type EN10MB (Ethernet), capture size 262144 bytes
10 packets captured
10 packets received by filter
0 packets dropped by kernel
[root@hf-01 ~]# file 1.cap
1.cap: tcpdump capture file (little-endian) - version 2.4 (Ethernet, capture length 262144)
[root@hf-01 ~]#
[root@hf-01 ~]# tcpdump -r 1.cap //查看1.cap文件
reading from file 1.cap, link-type EN10MB (Ethernet)
07:02:05.134302 IP 192.168.74.129.ssh > 192.168.74.1.49322: Flags [P.], seq 4218852344:4218852492, ack 3076966380, win 159, length 148
07:02:05.134859 IP 192.168.74.1.49322 > 192.168.74.129.ssh: Flags [.], ack 148, win 255, length 0
07:02:05.257655 IP 192.168.74.129.ssh > 192.168.74.1.49322: Flags [P.], seq 148:280, ack 1, win 159, length 132
07:02:05.462113 IP 192.168.74.1.49322 > 192.168.74.129.ssh: Flags [.], ack 280, win 255, length 0
07:02:06.258704 IP 192.168.74.129.ssh > 192.168.74.1.49322: Flags [P.], seq 280:428, ack 1, win 159, length 148
07:02:06.462164 IP 192.168.74.1.49322 > 192.168.74.129.ssh: Flags [.], ack 428, win 254, length 0
07:02:07.259714 IP 192.168.74.129.ssh > 192.168.74.1.49322: Flags [P.], seq 428:560, ack 1, win 159, length 132
07:02:07.460218 IP 192.168.74.1.49322 > 192.168.74.129.ssh: Flags [.], ack 560, win 254, length 0
07:02:08.260717 IP 192.168.74.129.ssh > 192.168.74.1.49322: Flags [P.], seq 560:708, ack 1, win 159, length 148
07:02:08.460263 IP 192.168.74.1.49322 > 192.168.74.129.ssh: Flags [.], ack 708, win 253, length 0
[root@hf-01 ~]#