Wireshark抓包过滤器使用BPF语法(Berkeley Packet Filter),基于libpcap/wincap库。
一、语法说明
1、类型Type
host、net、port
2、方向Dir
src、dst
3、协议Protocol
ether、ip、tcp、udp、http、ftp
4、逻辑运算符
&&与、||或、!非
二、实例演示
1、过滤MAC地址案例
ether host 8c:a6:df:42:55:56
ether src host 8c:a6:df:42:55:56
ether dst host 8c:a6:df:42:55:56
2、过滤IP地址案例
host 192.168.1.101
src host 192.168.1.101
dst host 192.168.1.101
3、过滤端口案例
port 80
!port 80
src port 80
dst port 80
4、过滤协议案例
arp
icmp
tcp
5、综合过滤案例
host 192.168.1.101 && port 8080 抓取地址为192.168.1.101且端口为8080的流量
src host 192.168.1.101 && dst port 8080 抓取源地址为192.168.1.101且目的端口号为8080的流量
host 192.168.1.1 || 192.168.1.2 抓取192.168.1.1和192.168.1.2的流量、