tcpdump工具

监视指定的网络接口/网卡

tcpdump -i eth100

 

通过网卡eth100监视主机的数据包

tcpdump -i eth100 host 190.160.35.11

 

截获本地发送到目标主机190.160.35.11的数据

tcpdump -i eth100 dst host 190.160.35.11

 

监视来自远程主机190.160.35.11发来本地的数据

tcpdump -i eth100 src host 190.160.35.11

 

指定tcp协议监视端口的数据

tcpdump -i eth100 tcp port 22

 

指定udp协议监视端口的数据

tcpdump -i eth100 udp port 1947

 

抓取源IP 190.160.35.11且端口不是22的数据

tcpdump -i eth100 -vnn src host 190.160.35.11 and not port 22

 

抓取源IP190.160.35.11且端口是22,或源IP190.160.35.15且目的端口是80的数据包

tcpdump -i eth100 -vnn 'src host 190.160.35.11 and dst port 22' or 'src host 190.160.35.15 and dst port 80'

 

抓取190.160.35.0/24这个网段来往的所有数据

tcpdump -i eth100 -vnn net 190.160.35.0/24

 

抓取icmp协议的数据包(ping)

tcpdump -i eth100 -vnn icmp

 

把抓取的数据包记录到 result.txt 文件中,抓取100次数据

tcpdump -i eth100 -vnn -w result.txt -c 100

 

result.txt记录中读取tcp协议的数据包

tcpdump -i eth100 -vnn -r result.txt tcp

 

result.txt记录中读取包含主机190.192.5.240的数据包

tcpdump -i eth100 -vnn -r result.txt host 190.192.5.240

 

参数详解

-i 指定网卡

-v 输出详细的信息

-nn 将监听的数据包中的域名转换成IP, 端口从系统内置运用名称转换成端口号

-w 将抓到的数据包结果写入到文件

-r 从制定文件读取数据包

原文地址:https://www.cnblogs.com/leiwenbin627/p/11873649.html