本文列举wireshark 常用的OSI三层抓包和显示过滤规则.

Wireshark Information

dupack过滤条件 wireshark wireshark info过滤_OSI

封包详细信息 (Packet Details Pane)

这个面板是我们最重要的,用来查看协议中的每一个字段。

各行信息分别为

Frame: 物理层的数据帧概况

Ethernet II: 数据链路层以太网帧头部信息

Internet Protocol Version 4: 互联网层IP包头部信息

Transmission Control Protocol: 传输层T的数据段头部信息,此处是TCP

Hypertext Transfer Protocol: 应用层的信息,此处是HTTP协议

wireshark与对应的OSI七层模型

dupack过滤条件 wireshark wireshark info过滤_OSI_02

wireshark 常用快捷键可以查看上一篇“二层抓包过滤文章”

一、抓包过滤表达式的规则(OSI 三层)

#ip/ipv6 只抓取IPv4或IPv6的数据包

dupack过滤条件 wireshark wireshark info过滤_网络_03

#IPV6 抓包规则

dupack过滤条件 wireshark wireshark info过滤_OSI_04

dupack过滤条件 wireshark wireshark info过滤_运维_05


#host X.X.X.X 只抓取源于或发往所指定的主机名或IP地址的流量(比如:host 192.168.1.1)

host 172.18.202.248

备注:对于同一个目标抓取报文,既可以抓取二层抓取规则,也可以采用三层抓取规则,其结果是一样的;

dupack过滤条件 wireshark wireshark info过滤_IP_06

dupack过滤条件 wireshark wireshark info过滤_网络_07


#dst host X.X.X.X 只抓取发往所指定的主机名或IP地址的流量

dst host 172.18.202.248 = dst 172.18.202.248

dupack过滤条件 wireshark wireshark info过滤_网络_08

dupack过滤条件 wireshark wireshark info过滤_OSI_09

dupack过滤条件 wireshark wireshark info过滤_DNS_10

#src host X.X.X.X 只抓取源于所指定的主机名或IP地址的流量

src host 172.18.202.248

dupack过滤条件 wireshark wireshark info过滤_IP_11

dupack过滤条件 wireshark wireshark info过滤_网络_12


#gateway X.X.X.X 只抓穿过host的流量

#net X.X.X.X 只抓取源于或发往标识符的IPv4huoIPv6网络号的流量(比如:net 192.168.1.0/24 或net 192.168.1.0 mask 255.255.255.0 )

net 172.18.202.0/24

dupack过滤条件 wireshark wireshark info过滤_运维_13


net X.X.X.X = 【dst net X.X.X.X + src net X.X.X.X】

dupack过滤条件 wireshark wireshark info过滤_IP_14


#dst net X.X.X.X 只抓取发往标识符的IPv4huoIPv6网络号的流量

dst net 172.22.202.0/24

dupack过滤条件 wireshark wireshark info过滤_网络_15

dupack过滤条件 wireshark wireshark info过滤_运维_16

#src net X.X.X.X 只抓取源于标识符的IPv4huoIPv6网络号的流量

src net 172.18.18.0/24

dupack过滤条件 wireshark wireshark info过滤_运维_17

dupack过滤条件 wireshark wireshark info过滤_OSI_18

broadcast 只抓取IP广播包

ip broadcast

dupack过滤条件 wireshark wireshark info过滤_IP_19

dupack过滤条件 wireshark wireshark info过滤_运维_20

multicast 只抓取IP多播包

ip6 multicast

dupack过滤条件 wireshark wireshark info过滤_运维_21

dupack过滤条件 wireshark wireshark info过滤_网络_22

ip multicast

dupack过滤条件 wireshark wireshark info过滤_DNS_23

dupack过滤条件 wireshark wireshark info过滤_IP_24

@混合表达式过滤规则

ip host 172.18.202.248 and icmp

dupack过滤条件 wireshark wireshark info过滤_IP_25

dupack过滤条件 wireshark wireshark info过滤_IP_26

src host 172.18.202.248 or arp

dupack过滤条件 wireshark wireshark info过滤_运维_27

dupack过滤条件 wireshark wireshark info过滤_DNS_28

src host 172.18.202.248 or (arp and !broadcast )

dupack过滤条件 wireshark wireshark info过滤_IP_29

dupack过滤条件 wireshark wireshark info过滤_运维_30

src host 172.18.202.248 or ( (arp and !broadcast ) and ! tcp)

dupack过滤条件 wireshark wireshark info过滤_网络_31

dupack过滤条件 wireshark wireshark info过滤_DNS_32

src host 172.18.202.248 and ( (arp and !broadcast ) and ! tcp)

dupack过滤条件 wireshark wireshark info过滤_OSI_33

net 172.18.202.0/24 and (arp and !broadcast ) or ! tcp

dupack过滤条件 wireshark wireshark info过滤_网络_34

dupack过滤条件 wireshark wireshark info过滤_OSI_35

net 172.18.200.0/21 and ether src 8C-EC-4B-69-A6-A7 and arp

dupack过滤条件 wireshark wireshark info过滤_网络_36

dupack过滤条件 wireshark wireshark info过滤_运维_37

二、显示过滤表达式的规则(OSI 三层)

混合表达式示例

ip.addr == 172.18.202.248 and not tcp.port in {80 25 1433}

--过滤显示ip等于172.18.202.248 并且 tcp端口不是80、25、1433的报文;

dupack过滤条件 wireshark wireshark info过滤_OSI_38

#ip proto XX 只抓取IP报头的协议类型字段值等于特定值的数据包

ip.proto

dupack过滤条件 wireshark wireshark info过滤_IP_39

ip.proto and tcp or http

dupack过滤条件 wireshark wireshark info过滤_DNS_40

tcp.dstport == 80

dupack过滤条件 wireshark wireshark info过滤_IP_41

#ip6 proto xx 只抓取IPv6报头的协议类型字段值等于特定值的数据包

ICMP

dupack过滤条件 wireshark wireshark info过滤_DNS_42

#TCP or udp

dupack过滤条件 wireshark wireshark info过滤_运维_43

ip.proto == 6

dupack过滤条件 wireshark wireshark info过滤_运维_44

ip.proto == 2

dupack过滤条件 wireshark wireshark info过滤_网络_45

常见的DNS显示过滤器
让Wireshark只显示DNS查询和DNS响应数据包

dns.flags.response== 0 (DNS 查询)

dns.flags.response== 1(DNS 响应)

dupack过滤条件 wireshark wireshark info过滤_网络_46

dupack过滤条件 wireshark wireshark info过滤_IP_47

dns

dupack过滤条件 wireshark wireshark info过滤_网络_48

ip.proto == 25

dupack过滤条件 wireshark wireshark info过滤_DNS_49

=========
常见的协议类型字段值
1 ICMP
2 IGMP
6 TCP
17 UDP
47 GRE
88 EIGRP
89 OSPF
112 VRRP

好了,今天就列举这么多,希望能对阅读者有所帮助。学以致用,多实践多总结。


转载于:https://blog.51cto.com/13637805/2337346