Linux环境下使用tcpdump抓包与下载

时间:2021-02-06 13:44:21

(1)报文抓取

tcpdump -i eno5 host 10.8.12.154 -w /test.cap

-i:抓取的网卡

host:目的地址

-w:生成的文件存放路径

Ctrl+c 结束抓包,抓取的报文存放在/的test.cap下

(2)报文获取

方法1:使用scp命令,将当前设备上/root下的set_fxs_port.cap文件传输到IP为10.8.12.90设备/mnt/hfs1目录下

[root@genewDB ~]# ll
total 20
-rw-r--r-- 1 tcpdump tcpdump 24 Sep 7 08:17 B1205F.pcap
drwxr-xr-x 2 root root 6 May 6 22:19 Desktop
drwxr-xr-x 2 root root 6 May 6 22:19 Documents
drwxr-xr-x 2 root root 6 May 6 22:19 Downloads
drwxr-xr-x 2 root root 6 May 6 22:19 Music
drwxrwxr-x 3 root root 19 Aug 9 11:38 Netman4000
drwxr-xr-x. 3 root root 17 May 4 08:50 Orgin_file
drwxr-xr-x 2 root root 6 May 6 22:19 Pictures
drwxr-xr-x 2 root root 6 May 6 22:19 Public
-rw-r--r-- 1 tcpdump tcpdump 1501 Sep 11 06:07 set_fxs_port.cap
-rw-r--r-- 1 tcpdump tcpdump 512 Sep 11 06:03 set+fxs_port.cap
drwxr-xr-x 2 root root 6 May 6 22:19 Templates
-rw-r--r-- 1 tcpdump tcpdump 7167 Aug 17 18:15 tongji.cap
drwxr-xr-x 2 root root 6 May 6 22:19 Videos
[root@genewDB ~]# pwd
/root
[root@genewDB ~]# scp /root/set_fxs_port.cap root@10.8.12.90:/mnt/hfs1/set_fxs_port.cap
root@10.8.12.90's password:
set_fxs_port.cap 100% 1501 1.5KB/s 00:00

方法2:使用SSH Secure File Transfer Client下载到本地;