安装
yum install tcpdump apt install tcpdump 介绍 tcpdump dump the traffic on a network,根据使用者的定义对网络上的数据包进行截获的包分析工具。参数
-i 接口,-c 包数量,-B 包大小,-r 读取包,-w 导出文件 host 主机ip,src/dst 源目的地址,等等实例
tcpdump -i eth0 抓取eth0口的双向数据包 tcpdump -i eth0 host 122.224.241.154 抓取eth0接口, 122.224.241.154收发的包 tcpdump -i eth0 host 30.30.30.30 and 40.40.40.40 抓取30.30.30.30和40.40.40.40收发的包 tcpdump -i eth0 src host 30.30.30.3 监视所有30.30.30.3发出的数据包 tcpdump -i eth0 host 122.224.241.154 and tcp port 80 -c 10 抓取122.224.241.154发送和接收的80端口的10个包 tcpdump -i eth0 net 10.109.130.0/24 抓取网络地址是10.109.130.0/24的发送和接收的数据包 tcpdump –i eth0 host 192.168.102.156 and icmp –c 10 抓取192.168.102.156的ping包10个 tcpdump -i eth0 dst host 192.168.107.216 and esp -nn 抓取发送到192.168.107.216的ESP数据包 tcpdump -i eth0 port 80 and host www.hao123.com or www.baidu.com 抓取发送到主机hao123或者百度的80端口的包 tcpdump -i eth0 host 192.168.107.216 -s 0 -c 20 –nnv -w /root/1.cap抓取主机192.168.107.216发送或者接收的ICMP数据包详细信息,数量是20个,并保存到root下,文件名是1.cap tcpdump -r /root/1.cap 读取1.cap包内容 VLAN和QINQ环境下抓包: vlan环境 tcpdump -i eth0 vlan and udp port 1812 or 1813 or 1645 or 1646 -s0 -w /icg/data/radius.pcap QINQ环境 tcpdump -i eth0 vlan and vlan and udp port 1812 or 1813 or 1645 or 1646 -s0 -w /icg/data/radius.pcap 注:由于vlan环境上行流量带vlan标签,而下行不带,此时抓包不带vlan参 数,可能只能抓到下行流量。标签:数据包,vlan,抓取,host,常用命令,tcpdump,抓包,eth0 From: https://www.cnblogs.com/gpysir/p/17026763.html