---
title: "Ethereal抓包过滤器表达式"
author: "haoppywang"
date: "2011-09-05T15:37:00Z"
tags: []
categories: ["行业应用"]
slug: "ethereal"
draft: false
lastmod: "2011-09-05T15:38:29Z"
id: 1165846
url: "https://haoppywang.iteye.com/blog/1165846"
---

下面是Ethereal帮助中给出的一些简单的例子：  
1\. Ethernet: capture all traffic to and from the Ethernet address 08:00:08:15:ca:fe  
    ether host 08:00:08:15:ca:fe  
2\. IP: capture all traffic to and from the IP address 192.168.0.10  
    host 192.168.0.10  
3\. TCP: capture all traffic to and from the TCP port 80 (http) of all machines  
    tcp port 80  
4\. combined: capture all traffic to and from 192.168.0.10 except http  
    host 192.168.0.10 and not tcp port 80  
【注意】上面例子表达式中的IP地址对于IP中嵌套IP来讲，仅对外层IP有效，对嵌套在IP包中的IP是无效的。

 

R6口抓包的例子  
表达式：ip\[6:2] & 0x1fff = 0  
表达式整体的含义为：从IP包中取出第6和第7（从0字节开始数）这2个字节，和0x1fff相与，如果结果为0，则抓取该包，否则丢掉。  
表达式：ip\[2:2] & 0xffff =0x005c  
按此表达式抓包，可以抓到所有长度为92字节的IP包，其它包被过滤掉，抓包文件中只有这些长度为92字节的PING包。