PCAP-filters are used for the following purposes:

The rules consist of a "rules list" and a decision by default (deny/permit). Each rule consists of a condition and a decision (deny/permit). While going through the list, the switch checks whether a packet matches the rule. If it matches the rule, the decision set for this rule is applied to the packet.

Otherwise, the list of rules is viewed further. Rules are taken one at a time. If a packet does not match to any rule, the default decision for this group or interface is taken.

The expression selects which packets will fit into the group. Only packets for which expression is 'true' will be matched to the group. The expression consists of one or more primitives. Primitives usually consist of an id (name or number) preceeded by one or more qualifiers.

Packet Filter Rule Examples

Single IP subnet:

net 192.168.1.0/24

Several IP subnets:

net 192.168.1.0/24 or net 192.168.100.0/24

Several IP subnets with exceptions:

net 192.168.1.0/16 and not net (192.168.100.0/24 or 192.168.200.0/24)

Several IP subnets inside VLAN:

vlan 50 and (net 192.168.1.0/24 or net 192.168.100.0/24)

DSCP labels:

ip[1]>>2 == 1 or ip[1]>>2 == 2vlan and (ip[1]>>2 > 5)

Disable IP multicast and broadcast:

not ip multicast

To select the start and end packets (the SYN and FIN packets) of each TCP conversation:

(tcp[tcpflags] & (tcp-syn|tcp-fin) != 0)

To select all ICMP packets that are not echo requests/replies (i.e., not ping packets):

icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply


Detailed filter expression syntax description

Detailed filter expression syntax description

Filter expression determines which packets will be selected by the filter for further processing. If no expression is given, all packets on the net will be selected. Otherwise, only packets for which expression is `true' will be selected.

The expression consists of one or more primitives. Primitives usually consist of an id (name or number) preceded by one or more qualifiers. There are three different kinds of qualifier:

In addition to the above, there are some special `primitive' keywords that don't follow the pattern: broadcastlessgreater and arithmetic expressions. All of these are described below.

More complex filter expressions are built up by using the words andor and not to combine primitives. E.g., `host foo and not port ftp and not port ftp-data'. To save typing, identical qualifier lists can be omitted. E.g., `tcp dst port ftp or ftp-data or domain' is exactly the same as `tcp dst port ftp or tcp dst port ftp-data or tcp dst port domain'.

Allowable primitives are:


Any of the above host expressions can be prefixed with the keywords, ipip6arprarp as in:

"ip host host"         

which is equivalent to:

"ether proto \ip and host host "        

Any of the above port or port range expressions can be prefixed with the keywords, tcp or udp, as in:

tcp src port port           

which matches only tcp packets whose source port is port.

"len <= length".

"len >= length".


In the case of Ethernet, WANFleX checks the Ethernet type field for most of those protocols. The exceptions are:

WANFLeX checks for an 802.3 frame and then checks the LLC header as it does for FDDI, Token Ring, and 802.11;

WANFLeX checks both for the AppleTalk etype in an Ethernet frame and for a SNAP-format packet as it does for FDDI, Token Ring, and 802.11;

WANFLeX checks for the AppleTalk ARP etype in either an Ethernet frame or an 802.2 SNAP frame with an OUI of 0x000000;

WANFLeX checks for the IPX etype in an Ethernet frame, the IPX DSAP in the LLC header, the 802.3-with-no-LLC-header encapsulation of IPX, and the IPX etype in a SNAP frame.


iparprarpatalkaarpisostpipxnetbeui

Abbreviations for:

ether proto p           

where p is one of the above protocols.


For example:

svlan 100 && vlan 200   

filters on VLAN 200 encapsulated within Service VLAN 100, and

vlan 300 && ip 

filters IPv4 protocols encapsulated in VLAN 300.

svlan 100   

filters all packets encapsulated within Service VLAN 100

For example:

mpls 100000 && mpls 1024       

filters packets with an outer label of 100000 and an inner label of 1024, and

mpls && mpls 1024 && host 192.9.200.1       

filters packets to or from 192.9.200.1 with an inner label of 1024 and any outer label.

For example:

pppoes && ppp proto 0x21      

filters IPv4 protocols encapsulated in PPPoE.

Abbreviations for:

"ip proto p", where p is one of the above protocols.

Abbreviations for:

"iso proto p" , where p is one of the above protocols.

True if the relation holds, where relop is one of >, <, >=, <=, =, !=, and expr is an arithmetic expression composed of integer constants (expressed in standard C syntax), the normal binary operators [+, -, *, /, &, |, <<, >>], a length operator, and special packet data accessors. Note that all comparisons are unsigned, so that, for example, 0x80000000 and 0xffffffff are > 0. To access data inside the packet, use the following syntax:

proto [ expr : size ]           

Proto is one of ether, fddi, tr, wlan, ppp, slip, link, ip, arp, rarp, tcp, udp, icmp, and indicates the protocol layer for the index operation. (ether, fddi, wlan, tr, ppp, slip and link all refer to the link layer.) Note that tcp, udp and other upper-layer protocol types only apply to IPv4. The byte offset, relative to the indicated protocol layer, is given by exprSize is optional and indicates the number of bytes in the field of interest; it can be either one, two, or four, and defaults to one. The length operator, indicated by the keyword len, gives the length of the packet.

For example, `ether[0] & 1 != 0' catches all multicast traffic. The expression `ip[0] & 0xf != 5' catches all IPv4 packets with options. The expression `ip[6:2] & 0x1fff = 0' catches only unfragmented IPv4 datagrams and frag zero of fragmented IPv4 datagrams. This check is implicitly applied to the tcp and udp index operations. For instance, tcp[0] always means the first byte of the TCP header, and never means the first byte of an intervening fragment.

Some offsets and field values may be expressed as names rather than as numeric values. The following protocol header field offsets are available: icmptype (ICMP type field), icmpcode (ICMP code field), and tcpflags (TCP flags field).

The following ICMP type field values are available: icmp-echoreplyicmp-unreachicmp-sourcequenchicmp-redirecticmp-echoicmp-routeradverticmp-routersoliciticmp-timxceedicmp-paramprobicmp-tstampicmp-tstampreplyicmp-ireqicmp-ireqreplyicmp-maskreqicmp-maskreply.

The following TCP flags field values are available: tcp-fintcp-syntcp-rsttcp-pushtcp-acktcp-urg.

Primitives may be combined using:

A parenthesized group of primitives and operators (parentheses are special to the Shell and must be escaped).

Negation has highest precedence. Alternation and concatenation have equal precedence and associate left to right. Note that explicit and tokens, not juxtaposition, are now required for concatenation.

If an identifier is given without a keyword, the most recent keyword is assumed. For example,

not host 1.1.1.1 and 2.2.2.2     

is short for

not host 1.1.1.1 and host 2.2.2.2 

which should not be confused with

not ( host 1.1.1.1 or 2.2.2.2 )