1 .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
2 .\" The Regents of the University of California. All rights reserved.
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that: (1) source code distributions
7 .\" retain the above copyright notice and this paragraph in its entirety, (2)
8 .\" distributions including binary code include the above copyright notice and
9 .\" this paragraph in its entirety in the documentation or other materials
10 .\" provided with the distribution, and (3) all advertising materials mentioning
11 .\" features or use of this software display the following acknowledgement:
12 .\" ``This product includes software developed by the University of California,
13 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 .\" the University nor the names of its contributors may be used to endorse
15 .\" or promote products derived from this software without specific prior
16 .\" written permission.
17 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 .TH PCAP-FILTER @MAN_MISC_INFO@ "6 February 2021"
23 pcap-filter \- packet filter syntax
29 is used to compile a string into a filter program.
30 The resulting filter program can then be applied to
31 some stream of packets to determine which packets will be supplied to
32 .BR pcap_loop (3PCAP),
33 .BR pcap_dispatch (3PCAP),
34 .BR pcap_next (3PCAP),
36 .BR pcap_next_ex (3PCAP).
38 The \fIfilter expression\fP consists of one or more
40 Primitives usually consist of an
42 (name or number) preceded by one or more qualifiers.
44 different kinds of qualifier:
47 qualifiers say what kind of thing the id name or number refers to.
54 E.g., `\fBhost\fP foo', `\fBnet\fP 128.3', `\fBport\fP 20', `\fBportrange\fP 6000-6008'.
61 qualifiers specify a particular transfer direction to and/or from
63 Possible directions are
75 E.g., `\fBsrc\fP foo', `\fBdst net\fP 128.3', `\fBsrc or dst port\fP ftp-data'.
77 there is no dir qualifier, `\fBsrc or dst\fP' is assumed.
86 qualifiers are only valid for IEEE 802.11 Wireless LAN link layers.
89 qualifiers restrict the match to a particular protocol.
104 E.g., `\fBether src\fP foo', `\fBarp net\fP 128.3', `\fBtcp port\fP 21',
105 `\fBudp portrange\fP 7000-7009', `\fBwlan addr2\fP 0:2:3:4:5:6'.
107 no proto qualifier, all protocols consistent with the type are
109 E.g., `\fBsrc\fP foo' means `\fB(ip or arp or rarp) src\fP foo'
110 (except the latter is not legal syntax), `\fBnet\fP bar' means `\fB(ip or
111 arp or rarp) net\fP bar' and `\fBport\fP 53' means `\fB(tcp or udp)
114 [\fBfddi\fP is actually an alias for \fBether\fP; the parser treats them
115 identically as meaning ``the data link level used on the specified
116 network interface''. FDDI headers contain Ethernet-like source
117 and destination addresses, and often contain Ethernet-like packet
118 types, so you can filter on these FDDI fields just as with the
119 analogous Ethernet fields.
120 FDDI headers also contain other fields,
121 but you cannot name them explicitly in a filter expression.
123 Similarly, \fBtr\fP and \fBwlan\fP are aliases for \fBether\fP; the previous
124 paragraph's statements about FDDI headers also apply to Token Ring
125 and 802.11 wireless LAN headers. For 802.11 headers, the destination
126 address is the DA field and the source address is the SA field; the
127 BSSID, RA, and TA fields aren't tested.]
129 In addition to the above, there are some special `primitive' keywords
130 that don't follow the pattern:
135 and arithmetic expressions.
136 All of these are described below.
138 More complex filter expressions are built up by using the words
143 (or equivalently: `\fB&&\fP', `\fB||\fP' and `\fB!\fP' respectively)
144 to combine primitives.
145 E.g., `\fBhost\fP foo \fBand not port\fP ftp \fBand not port\fP ftp-data'.
146 To save typing, identical qualifier lists can be omitted.
148 `\fBtcp dst port\fP ftp \fBor\fP ftp-data \fBor\fP domain' is exactly the same as
149 `\fBtcp dst port\fP ftp \fBor tcp dst port\fP ftp-data \fBor tcp dst port\fP domain'.
151 Allowable primitives are:
152 .IP "\fBdst host \fIhost\fR"
153 True if the IPv4/v6 destination field of the packet is \fIhost\fP,
154 which may be either an address or a name.
155 .IP "\fBsrc host \fIhost\fR"
156 True if the IPv4/v6 source field of the packet is \fIhost\fP.
157 .IP "\fBhost \fIhost\fP"
158 True if either the IPv4/v6 source or destination of the packet is \fIhost\fP.
160 Any of the above host expressions can be prepended with the keywords,
161 \fBip\fP, \fBarp\fP, \fBrarp\fP, or \fBip6\fP as in:
164 \fBip host \fIhost\fR
167 which is equivalent to:
170 \fBether proto \\ip and host \fIhost\fR
173 If \fIhost\fR is a name with multiple IPv4 addresses, each address will
174 be checked for a match.
175 .IP "\fBether dst \fIehost\fP"
176 True if the Ethernet destination address is \fIehost\fP.
178 may be either a name from /etc/ethers or a numerical MAC address of the
179 form "xx:xx:xx:xx:xx:xx", "xx.xx.xx.xx.xx.xx", "xx-xx-xx-xx-xx-xx",
180 "xxxx.xxxx.xxxx", "xxxxxxxxxxxx", or various mixes of ':', '.', and '-',
181 where each "x" is a hex digit (0-9, a-f, or A-F).
182 .IP "\fBether src \fIehost\fP"
183 True if the Ethernet source address is \fIehost\fP.
184 .IP "\fBether host \fIehost\fP"
185 True if either the Ethernet source or destination address is \fIehost\fP.
186 .IP "\fBgateway\fP \fIhost\fP"
187 True if the packet used \fIhost\fP as a gateway.
189 source or destination address was \fIhost\fP but neither the IP source
190 nor the IP destination was \fIhost\fP.
191 \fIHost\fP must be a name and
192 must be found both by the machine's host-name-to-IP-address resolution
193 mechanisms (host name file, DNS, NIS, etc.) and by the machine's
194 host-name-to-Ethernet-address resolution mechanism (/etc/ethers, etc.).
195 (An equivalent expression is
198 \fBether host \fIehost \fBand not host \fIhost\fR
201 which can be used with either names or numbers for \fIhost / ehost\fP.)
202 This syntax does not work in IPv6-enabled configuration at this moment.
203 .IP "\fBdst net \fInet\fR"
204 True if the IPv4/v6 destination address of the packet has a network
206 \fINet\fP may be either a name from the networks database
207 (/etc/networks, etc.) or a network number.
208 An IPv4 network number can be written as a dotted quad (e.g., 192.168.1.0),
209 dotted triple (e.g., 192.168.1), dotted pair (e.g, 172.16), or single
210 number (e.g., 10); the netmask is 255.255.255.255 for a dotted quad
211 (which means that it's really a host match), 255.255.255.0 for a dotted
212 triple, 255.255.0.0 for a dotted pair, or 255.0.0.0 for a single number.
213 An IPv6 network number must be written out fully; the netmask is
214 ff:ff:ff:ff:ff:ff:ff:ff, so IPv6 "network" matches are really always
215 host matches, and a network match requires a netmask length.
216 .IP "\fBsrc net \fInet\fR"
217 True if the IPv4/v6 source address of the packet has a network
219 .IP "\fBnet \fInet\fR"
220 True if either the IPv4/v6 source or destination address of the packet has a network
222 .IP "\fBnet \fInet\fR \fBmask \fInetmask\fR"
223 True if the IPv4 address matches \fInet\fR with the specific \fInetmask\fR.
224 May be qualified with \fBsrc\fR or \fBdst\fR.
225 Note that this syntax is not valid for IPv6 \fInet\fR.
226 .IP "\fBnet \fInet\fR/\fIlen\fR"
227 True if the IPv4/v6 address matches \fInet\fR with a netmask \fIlen\fR
229 May be qualified with \fBsrc\fR or \fBdst\fR.
230 .IP "\fBdst port \fIport\fR"
231 True if the packet is IPv4 TCP, IPv4 UDP, IPv6 TCP or IPv6 UDP and has a
232 destination port value of \fIport\fP.
233 The \fIport\fP can be a number or a name used in /etc/services (see
237 If a name is used, both the port
238 number and protocol are checked.
239 If a number or ambiguous name is used,
240 only the port number is checked (e.g., `\fBdst port\fR 513' will print both
241 tcp/login traffic and udp/who traffic, and `\fBport domain\fR' will print
242 both tcp/domain and udp/domain traffic).
243 .IP "\fBsrc port \fIport\fR"
244 True if the packet has a source port value of \fIport\fP.
245 .IP "\fBport \fIport\fR"
246 True if either the source or destination port of the packet is \fIport\fP.
247 .IP "\fBdst portrange \fIport1-port2\fR"
248 True if the packet is IPv4 TCP, IPv4 UDP, IPv6 TCP or IPv6 UDP and has a
249 destination port value between \fIport1\fP and \fIport2\fP (both inclusive).
253 are interpreted in the same fashion as the
257 .IP "\fBsrc portrange \fIport1-port2\fR"
258 True if the packet has a source port value between \fIport1\fP and
259 \fIport2\fP (both inclusive).
260 .IP "\fBportrange \fIport1-port2\fR"
261 True if either the source or destination port of the packet is between
262 \fIport1\fP and \fIport2\fP (both inclusive).
264 Any of the above port or port range expressions can be prepended with
265 the keywords, \fBtcp\fP or \fBudp\fP, as in:
268 \fBtcp src port \fIport\fR
271 which matches only TCP packets whose source port is \fIport\fP.
272 .IP "\fBless \fIlength\fR"
273 True if the packet has a length less than or equal to \fIlength\fP.
274 This is equivalent to:
277 \fBlen <= \fIlength\fP
280 .IP "\fBgreater \fIlength\fR"
281 True if the packet has a length greater than or equal to \fIlength\fP.
282 This is equivalent to:
285 \fBlen >= \fIlength\fP
288 .IP "\fBip proto \fIprotocol\fR"
289 True if the packet is an IPv4 packet (see
291 of protocol type \fIprotocol\fP.
292 \fIProtocol\fP can be a number or one of the names
293 \fBicmp\fP, \fBicmp6\fP, \fBigmp\fP, \fBigrp\fP, \fBpim\fP, \fBah\fP,
294 \fBesp\fP, \fBvrrp\fP, \fBudp\fP, or \fBtcp\fP.
295 Note that the identifiers \fBtcp\fP, \fBudp\fP, and \fBicmp\fP are also
296 keywords and must be escaped via backslash (\\).
297 Note that this primitive does not chase the protocol header chain.
298 .IP "\fBip6 proto \fIprotocol\fR"
299 True if the packet is an IPv6 packet of protocol type \fIprotocol\fP.
300 Note that this primitive does not chase the protocol header chain.
301 .IP "\fBproto \fIprotocol\fR"
302 True if the packet is an IPv4 or IPv6 packet of protocol type
303 \fIprotocol\fP. Note that this primitive does not chase the protocol
305 .IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR"
309 \fBproto \\\fIprotocol\fR\fB
312 where \fIprotocol\fR is one of the above protocols.
313 .IP "\fBip6 protochain \fIprotocol\fR"
314 True if the packet is IPv6 packet,
315 and contains protocol header with type \fIprotocol\fR
316 in its protocol header chain.
320 \fBip6 protochain\fR 6
323 matches any IPv6 packet with TCP protocol header in the protocol header chain.
324 The packet may contain, for example,
325 authentication header, routing header, or hop-by-hop option header,
326 between IPv6 header and TCP header.
327 The BPF code emitted by this primitive is complex and
328 cannot be optimized by the BPF optimizer code, and is not supported by
329 filter engines in the kernel, so this can be somewhat slow, and may
330 cause more packets to be dropped.
331 .IP "\fBip protochain \fIprotocol\fR"
332 Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4.
333 .IP "\fBprotochain \fIprotocol\fR"
334 True if the packet is an IPv4 or IPv6 packet of protocol type
335 \fIprotocol\fP. Note that this primitive chases the protocol
337 .IP "\fBether broadcast\fR"
338 True if the packet is an Ethernet broadcast packet.
341 .IP "\fBip broadcast\fR"
342 True if the packet is an IPv4 broadcast packet.
343 It checks for both the all-zeroes and all-ones broadcast conventions,
344 and looks up the subnet mask on the interface on which the capture is
347 If the subnet mask of the interface on which the capture is being done
348 is not available, either because the interface on which capture is being
349 done has no netmask or because the capture is being done on the Linux
350 "any" interface, which can capture on more than one interface, this
351 check will not work correctly.
352 .IP "\fBether multicast\fR"
353 True if the packet is an Ethernet multicast packet.
356 This is shorthand for `\fBether[\fP0\fB] & \fP1\fB != \fP0'.
357 .IP "\fBip multicast\fR"
358 True if the packet is an IPv4 multicast packet.
359 .IP "\fBip6 multicast\fR"
360 True if the packet is an IPv6 multicast packet.
361 .IP "\fBether proto \fIprotocol\fR"
362 True if the packet is of ether type \fIprotocol\fR.
363 \fIProtocol\fP can be a number or one of the names
364 \fBaarp\fP, \fBarp\fP, \fBatalk\fP, \fBdecnet\fP, \fBip\fP, \fBip6\fP,
365 \fBipx\fP, \fBiso\fP, \fBlat\fP, \fBloopback\fP, \fBmopdl\fP, \fBmoprc\fP, \fBnetbeui\fP,
366 \fBrarp\fP, \fBsca\fP or \fBstp\fP.
367 Note these identifiers (except \fBloopback\fP) are also keywords
368 and must be escaped via backslash (\\).
370 [In the case of FDDI (e.g., `\fBfddi proto \\arp\fR'), Token Ring
371 (e.g., `\fBtr proto \\arp\fR'), and IEEE 802.11 wireless LANs (e.g.,
372 `\fBwlan proto \\arp\fR'), for most of those protocols, the
373 protocol identification comes from the 802.2 Logical Link Control (LLC)
374 header, which is usually layered on top of the FDDI, Token Ring, or
377 When filtering for most protocol identifiers on FDDI, Token Ring, or
378 802.11, the filter checks only the protocol ID field of an LLC header
379 in so-called SNAP format with an Organizational Unit Identifier (OUI) of
380 0x000000, for encapsulated Ethernet; it doesn't check whether the packet
381 is in SNAP format with an OUI of 0x000000.
386 the filter checks the DSAP (Destination Service Access Point) and
387 SSAP (Source Service Access Point) fields of the LLC header;
389 \fBstp\fP and \fBnetbeui\fP
390 the filter checks the DSAP of the LLC header;
393 the filter checks for a SNAP-format packet with an OUI of 0x080007
394 and the AppleTalk etype.
397 In the case of Ethernet, the filter checks the Ethernet type field
398 for most of those protocols. The exceptions are:
401 \fBiso\fP, \fBstp\fP, and \fBnetbeui\fP
402 the filter checks for an 802.3 frame and then checks the LLC header as
403 it does for FDDI, Token Ring, and 802.11;
406 the filter checks both for the AppleTalk etype in an Ethernet frame and
407 for a SNAP-format packet as it does for FDDI, Token Ring, and 802.11;
410 the filter checks for the AppleTalk ARP etype in either an Ethernet
411 frame or an 802.2 SNAP frame with an OUI of 0x000000;
414 the filter checks for the IPX etype in an Ethernet frame, the IPX
415 DSAP in the LLC header, the 802.3-with-no-LLC-header encapsulation of
416 IPX, and the IPX etype in a SNAP frame.
418 .IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fBnetbeui\fP"
422 \fBether proto \\\fIprotocol\fR
425 where \fIprotocol\fR is one of the above protocols.
426 .IP "\fBlat\fR, \fBmoprc\fR, \fBmopdl\fR"
430 \fBether proto \\\fIprotocol\fR
433 where \fIprotocol\fR is one of the above protocols.
434 Note that not all applications using
436 currently know how to parse these protocols.
437 .IP "\fBdecnet src \fIhost\fR"
438 True if the DECnet source address is
440 which may be an address of the form ``10.123'', or a DECnet host
442 [DECnet host name support is only available on ULTRIX systems
443 that are configured to run DECnet.]
444 .IP "\fBdecnet dst \fIhost\fR"
445 True if the DECnet destination address is
447 .IP "\fBdecnet host \fIhost\fR"
448 True if either the DECnet source or destination address is
451 True if the packet has an 802.2 LLC header. This includes:
453 Ethernet packets with a length field rather than a type field that
454 aren't raw NetWare-over-802.3 packets;
456 IEEE 802.11 data packets;
458 Token Ring packets (no check is done for LLC frames);
460 FDDI packets (no check is done for LLC frames);
462 LLC-encapsulated ATM packets, for SunATM on Solaris.
463 .IP "\fBllc\fP \fItype\fR"
464 True if the packet has an 802.2 LLC header and has the specified
480 Receiver Ready (RR) S PDUs
483 Receiver Not Ready (RNR) S PDUs
489 Unnumbered Information (UI) U PDUs
492 Unnumbered Acknowledgment (UA) U PDUs
495 Disconnect (DISC) U PDUs
498 Set Asynchronous Balanced Mode Extended (SABME) U PDUs
504 Exchange Identification (XID) U PDUs
507 Frame Reject (FRMR) U PDUs
510 Packet was received by the host performing the capture rather than being
511 sent by that host. This is only supported for certain link-layer types,
512 such as SLIP and the ``cooked'' Linux capture mode
513 used for the ``any'' device and for some other device types.
515 Packet was sent by the host performing the capture rather than being
516 received by that host. This is only supported for certain link-layer types,
517 such as SLIP and the ``cooked'' Linux capture mode
518 used for the ``any'' device and for some other device types.
519 .IP "\fBifname \fIinterface\fR"
520 True if the packet was logged as coming from the specified interface (applies
521 only to packets logged by OpenBSD's or FreeBSD's
523 .IP "\fBon \fIinterface\fR"
527 .IP "\fBrnr \fInum\fR"
528 True if the packet was logged as matching the specified PF rule number
529 (applies only to packets logged by OpenBSD's or FreeBSD's
531 .IP "\fBrulenum \fInum\fR"
535 .IP "\fBreason \fIcode\fR"
536 True if the packet was logged with the specified PF reason code. The known
545 (applies only to packets logged by OpenBSD's or FreeBSD's
547 .IP "\fBrset \fIname\fR"
548 True if the packet was logged as matching the specified PF ruleset
549 name of an anchored ruleset (applies only to packets logged by OpenBSD's
552 .IP "\fBruleset \fIname\fR"
556 .IP "\fBsrnr \fInum\fR"
557 True if the packet was logged as matching the specified PF rule number
558 of an anchored ruleset (applies only to packets logged by OpenBSD's or
561 .IP "\fBsubrulenum \fInum\fR"
565 .IP "\fBaction \fIact\fR"
566 True if PF took the specified action when the packet was logged. Known actions
571 and, with later versions of
578 (applies only to packets logged by OpenBSD's or FreeBSD's
580 .IP "\fBwlan ra \fIehost\fR"
581 True if the IEEE 802.11 RA is
583 The RA field is used in all frames except for management frames.
584 .IP "\fBwlan ta \fIehost\fR"
585 True if the IEEE 802.11 TA is
587 The TA field is used in all frames except for management frames and
588 CTS (Clear To Send) and ACK (Acknowledgment) control frames.
589 .IP "\fBwlan addr1 \fIehost\fR"
590 True if the first IEEE 802.11 address is
592 .IP "\fBwlan addr2 \fIehost\fR"
593 True if the second IEEE 802.11 address, if present, is
595 The second address field is used in all frames except for CTS (Clear To
596 Send) and ACK (Acknowledgment) control frames.
597 .IP "\fBwlan addr3 \fIehost\fR"
598 True if the third IEEE 802.11 address, if present, is
600 The third address field is used in management and data frames, but not
602 .IP "\fBwlan addr4 \fIehost\fR"
603 True if the fourth IEEE 802.11 address, if present, is
605 The fourth address field is only used for
606 WDS (Wireless Distribution System) frames.
607 .IP "\fBtype \fIwlan_type\fR"
608 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR.
609 Valid \fIwlan_type\fRs are:
613 .IP "\fBtype \fIwlan_type \fBsubtype \fIwlan_subtype\fR"
614 True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR
615 and frame subtype matches the specified \fIwlan_subtype\fR.
617 If the specified \fIwlan_type\fR is \fBmgt\fP,
618 then valid \fIwlan_subtype\fRs are:
631 If the specified \fIwlan_type\fR is \fBctl\fP,
632 then valid \fIwlan_subtype\fRs are:
642 If the specified \fIwlan_type\fR is \fBdata\fP,
643 then valid \fIwlan_subtype\fRs are:
647 \fBdata-cf-ack-poll\fP,
653 \fBqos-data-cf-ack\fP,
654 \fBqos-data-cf-poll\fP,
655 \fBqos-data-cf-ack-poll\fP,
657 \fBqos-cf-poll\fP and
658 \fBqos-cf-ack-poll\fP.
659 .IP "\fBsubtype \fIwlan_subtype\fR"
660 True if the IEEE 802.11 frame subtype matches the specified \fIwlan_subtype\fR
661 and frame has the type to which the specified \fIwlan_subtype\fR belongs.
662 .IP "\fBdir \fIdir\fR"
663 True if the IEEE 802.11 frame direction matches the specified
665 Valid directions are:
671 .IP "\fBvlan \fI[vlan_id]\fR"
672 True if the packet is an IEEE 802.1Q VLAN packet.
673 If the optional \fIvlan_id\fR is specified, only true if the packet has the specified
675 Note that the first \fBvlan\fR keyword encountered in an expression
676 changes the decoding offsets for the remainder of the expression on
677 the assumption that the packet is a VLAN packet. The `\fBvlan
678 \fI[vlan_id]\fR` keyword may be used more than once, to filter on VLAN
679 hierarchies. Each use of that keyword increments the filter offsets
685 \fBvlan\fP 100 \fB&& vlan\fR 200
688 filters on VLAN 200 encapsulated within VLAN 100, and
691 \fBvlan && vlan \fP300 \fB&& ip\fR
694 filters IPv4 protocol encapsulated in VLAN 300 encapsulated within any
696 .IP "\fBmpls \fI[label_num]\fR"
697 True if the packet is an MPLS packet.
698 If the optional \fIlabel_num\fR is specified, only true if the packet has the specified
700 Note that the first \fBmpls\fR keyword encountered in an expression
701 changes the decoding offsets for the remainder of the expression on
702 the assumption that the packet is a MPLS-encapsulated IP packet. The
703 `\fBmpls \fI[label_num]\fR` keyword may be used more than once, to
704 filter on MPLS hierarchies. Each use of that keyword increments the
710 \fBmpls\fP 100000 \fB&& mpls\fR 1024
713 filters packets with an outer label of 100000 and an inner label of
717 \fBmpls && mpls\fP 1024 \fB&& host\fR 192.9.200.1
720 filters packets to or from 192.9.200.1 with an inner label of 1024 and
723 True if the packet is a PPP-over-Ethernet Discovery packet (Ethernet
725 .IP "\fBpppoes \fI[session_id]\fR"
726 True if the packet is a PPP-over-Ethernet Session packet (Ethernet
728 If the optional \fIsession_id\fR is specified, only true if the packet has the specified
730 Note that the first \fBpppoes\fR keyword encountered in an expression
731 changes the decoding offsets for the remainder of the expression on
732 the assumption that the packet is a PPPoE session packet.
737 \fBpppoes\fP 0x27 \fB&& ip\fR
740 filters IPv4 protocol encapsulated in PPPoE session id 0x27.
741 .IP "\fBgeneve \fI[vni]\fR"
742 True if the packet is a Geneve packet (UDP port 6081). If the optional \fIvni\fR
743 is specified, only true if the packet has the specified \fIvni\fR.
744 Note that when the \fBgeneve\fR keyword is encountered in
745 an expression, it changes the decoding offsets for the remainder of
746 the expression on the assumption that the packet is a Geneve packet.
751 \fBgeneve\fP 0xb \fB&& ip\fR
754 filters IPv4 protocol encapsulated in Geneve with VNI 0xb. This will
755 match both IPv4 directly encapsulated in Geneve as well as IPv4 contained
756 inside an Ethernet frame.
757 .IP "\fBiso proto \fIprotocol\fR"
758 True if the packet is an OSI packet of protocol type \fIprotocol\fP.
759 \fIProtocol\fP can be a number or one of the names
760 \fBclnp\fP, \fBesis\fP, or \fBisis\fP.
761 .IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR"
765 \fBiso proto \\\fIprotocol\fR
768 where \fIprotocol\fR is one of the above protocols.
769 .IP "\fBl1\fR, \fBl2\fR, \fBiih\fR, \fBlsp\fR, \fBsnp\fR, \fBcsnp\fR, \fBpsnp\fR"
770 Abbreviations for IS-IS PDU types.
771 .IP "\fBvpi\fP \fIn\fR"
772 True if the packet is an ATM packet, for SunATM on Solaris, with a
773 virtual path identifier of
775 .IP "\fBvci\fP \fIn\fR"
776 True if the packet is an ATM packet, for SunATM on Solaris, with a
777 virtual channel identifier of
780 True if the packet is an ATM packet, for SunATM on Solaris, and is
782 Note that the first \fBlane\fR keyword encountered in an expression
783 changes the tests done in the remainder of the expression
784 on the assumption that the packet is either a LANE emulated Ethernet
785 packet or a LANE LE Control packet. If \fBlane\fR isn't specified, the
786 tests are done under the assumption that the packet is an
787 LLC-encapsulated packet.
789 True if the packet is an ATM packet, for SunATM on Solaris, and is
790 a segment OAM F4 flow cell (VPI=0 & VCI=3).
792 True if the packet is an ATM packet, for SunATM on Solaris, and is
793 an end-to-end OAM F4 flow cell (VPI=0 & VCI=4).
795 True if the packet is an ATM packet, for SunATM on Solaris, and is
796 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
798 True if the packet is an ATM packet, for SunATM on Solaris, and is
799 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
801 True if the packet is an ATM packet, for SunATM on Solaris, and is
802 on a meta signaling circuit (VPI=0 & VCI=1).
804 True if the packet is an ATM packet, for SunATM on Solaris, and is
805 on a broadcast signaling circuit (VPI=0 & VCI=2).
807 True if the packet is an ATM packet, for SunATM on Solaris, and is
808 on a signaling circuit (VPI=0 & VCI=5).
810 True if the packet is an ATM packet, for SunATM on Solaris, and is
811 on an ILMI circuit (VPI=0 & VCI=16).
813 True if the packet is an ATM packet, for SunATM on Solaris, and is
814 on a signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
815 Connect Ack, Release, or Release Done message.
816 .IP \fBmetaconnect\fP
817 True if the packet is an ATM packet, for SunATM on Solaris, and is
818 on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
819 Release, or Release Done message.
820 .IP "\fIexpr relop expr\fR"
821 True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =
822 or ==, !=, and \fIexpr\fR is an arithmetic expression composed of integer
823 constants (expressed in standard C syntax), the normal binary operators
824 [+, -, *, /, %, &, |, ^, <<, >>], a length operator, and special packet data
825 accessors. Note that all comparisons are unsigned, so that, for example,
826 0x80000000 and 0xffffffff are > 0.
828 The % and ^ operators are currently only supported for filtering in the
829 kernel on Linux with 3.7 and later kernels; on all other systems, if
830 those operators are used, filtering will be done in user mode, which
831 will increase the overhead of capturing packets and may cause more
832 packets to be dropped.
834 To access data inside the packet, use the following syntax:
837 \fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR
840 \fIProto\fR is one of \fBether, fddi, tr, wlan, ppp, slip, link,
841 ip, arp, rarp, tcp, udp, icmp, ip6\fR or \fBradio\fR, and
842 indicates the protocol layer for the index operation.
843 (\fBether, fddi, wlan, tr, ppp, slip\fR and \fBlink\fR all refer to the
844 link layer. \fBradio\fR refers to the "radio header" added to some
846 Note that \fBtcp\fR, \fBudp\fR and other upper-layer protocol types only
847 apply to IPv4, not IPv6 (this will be fixed in the future).
848 The byte offset, relative to the indicated protocol layer, is
850 \fISize\fR is optional and indicates the number of bytes in the
851 field of interest; it can be either one, two, or four, and defaults to one.
852 The length operator, indicated by the keyword \fBlen\fP, gives the
853 length of the packet.
855 For example, `\fBether[\fP0\fB] &\fP 1 \fB!=\fP 0' catches all multicast traffic.
856 The expression `\fBip[\fP0\fB] &\fP 0xf \fB!=\fP 5'
857 catches all IPv4 packets with options.
859 `\fBip[\fP6:2\fB] &\fP 0x1fff \fB=\fP 0'
860 catches only unfragmented IPv4 datagrams and frag zero of fragmented
862 This check is implicitly applied to the \fBtcp\fP and \fBudp\fP
864 For instance, \fBtcp[\fP0\fB]\fP always means the first
865 byte of the TCP \fIheader\fP, and never means the first byte of an
866 intervening fragment.
868 Some offsets and field values may be expressed as names rather than
870 The following protocol header field offsets are
871 available: \fBicmptype\fP (ICMP type field), \fBicmp6type\fP (ICMPv6 type field),
872 \fBicmpcode\fP (ICMP code field), \fBicmp6code\fP (ICMPv6 code field) and
873 \fBtcpflags\fP (TCP flags field).
875 The following ICMP type field values are available: \fBicmp-echoreply\fP,
876 \fBicmp-unreach\fP, \fBicmp-sourcequench\fP, \fBicmp-redirect\fP,
877 \fBicmp-echo\fP, \fBicmp-routeradvert\fP, \fBicmp-routersolicit\fP,
878 \fBicmp-timxceed\fP, \fBicmp-paramprob\fP, \fBicmp-tstamp\fP,
879 \fBicmp-tstampreply\fP, \fBicmp-ireq\fP, \fBicmp-ireqreply\fP,
880 \fBicmp-maskreq\fP, \fBicmp-maskreply\fP.
882 The following ICMPv6 type fields are available: \fBicmp6-destinationrunreach\fP,
883 \fBicmp6-packettoobig\fP, \fBicmp6-timeexceeded\fP,
884 \fBicmp6-parameterproblem\fP, \fBicmp6-echo\fP,
885 \fBicmp6-echoreply\fP, \fBicmp6-multicastlistenerquery\fP,
886 \fBicmp6-multicastlistenerreportv1\fP, \fBicmp6-multicastlistenerdone\fP,
887 \fBicmp6-routersolicit\fP, \fBicmp6-routeradvert\fP,
888 \fBicmp6-neighborsolicit\fP, \fBicmp6-neighboradvert\fP, \fBicmp6-redirect\fP,
889 \fBicmp6-routerrenum\fP, \fBicmp6-nodeinformationquery\fP,
890 \fBicmp6-nodeinformationresponse\fP, \fBicmp6-ineighbordiscoverysolicit\fP,
891 \fBicmp6-ineighbordiscoveryadvert\fP, \fBicmp6-multicastlistenerreportv2\fP,
892 \fBicmp6-homeagentdiscoveryrequest\fP, \fBicmp6-homeagentdiscoveryreply\fP,
893 \fBicmp6-mobileprefixsolicit\fP, \fBicmp6-mobileprefixadvert\fP,
894 \fBicmp6-certpathsolicit\fP, \fBicmp6-certpathadvert\fP,
895 \fBicmp6-multicastrouteradvert\fP, \fBicmp6-multicastroutersolicit\fP,
896 \fBicmp6-multicastrouterterm\fP.
898 The following TCP flags field values are available: \fBtcp-fin\fP,
899 \fBtcp-syn\fP, \fBtcp-rst\fP, \fBtcp-push\fP,
900 \fBtcp-ack\fP, \fBtcp-urg\fP, \fBtcp-ece\fP,
903 Primitives may be combined using:
905 A parenthesized group of primitives and operators.
907 Negation (`\fB!\fP' or `\fBnot\fP').
909 Concatenation (`\fB&&\fP' or `\fBand\fP').
911 Alternation (`\fB||\fP' or `\fBor\fP').
913 Negation has the highest precedence.
914 Alternation and concatenation have equal precedence and associate
916 Note that explicit \fBand\fR tokens, not juxtaposition,
917 are now required for concatenation.
919 If an identifier is given without a keyword, the most recent keyword
924 \fBnot host\fP vs \fBand\fR ace
930 \fBnot host\fP vs \fBand host\fR ace
933 which should not be confused with
936 \fBnot (host \fPvs\fB or \fPace\fB)\fR
941 To select all packets arriving at or departing from `sundown':
948 To select traffic between `helios' and either `hot' or `ace':
951 \fBhost\fP helios \fBand (\fPhot \fBor\fP ace\fB)\fP
955 To select all IPv4 packets between `ace' and any host except `helios':
958 \fBip host\fP ace \fBand not\fP helios
962 To select all traffic between local hosts and hosts at Berkeley:
969 To select all FTP traffic through Internet gateway `snup':
972 \fBgateway\fP snup \fBand (port\fP ftp \fBor\fP ftp-data\fB)\fP
976 To select IPv4 traffic neither sourced from nor destined for local hosts
977 (if you gateway to one other net, this stuff should never make it
978 onto your local net).
981 \fBip and not net \fPlocalnet
985 To select the start and end packets (the SYN and FIN packets) of each
986 TCP conversation that involves a non-local host.
989 \fBtcp[tcpflags] & (tcp-syn|tcp-fin) !=\fP 0 \fBand not src and dst net\fP localnet
993 To select the TCP packets with flags RST and ACK both set.
994 (i.e. select only the RST and ACK flags in the flags field, and if the result
995 is "RST and ACK both set", match)
999 tcp[tcpflags] & (tcp-rst|tcp-ack) == (tcp-rst|tcp-ack)
1003 To select all IPv4 HTTP packets to and from port 80, i.e. print only
1004 packets that contain data, not, for example, SYN and FIN packets and
1005 ACK-only packets. (IPv6 is left as an exercise for the reader.)
1008 \fBtcp port\fP 80 \fBand (((ip[\fP2:2\fB] - ((ip[\fP0\fB]&\fP0xf\fB)<<\fP2\fB)) - ((tcp[\fP12\fB]&\fP0xf0\fB)>>\fP2\fB)) != \fP0\fB)
1012 To select IPv4 packets longer than 576 bytes sent through gateway `snup':
1015 \fBgateway\fP snup \fBand ip[\fP2:2\fB] >\fP 576
1019 To select IPv4 broadcast or multicast packets that were
1021 sent via Ethernet broadcast or multicast:
1024 \fBether[\fP0\fB] &\fP 1 \fB=\fP 0 \fBand ip[\fP16\fB] >=\fP 224
1028 To select all ICMP packets that are not echo requests/replies (i.e., not
1033 icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply
1035 icmp6[icmp6type] != icmp6-echo and icmp6[icmp6type] != icmp6-echoreply
1041 To report a security issue please send an e-mail to security@tcpdump.org.
1043 To report bugs and other problems, contribute patches, request a
1044 feature, provide generic feedback etc please see the file
1046 in the libpcap source tree root.
1048 Filter expressions on fields other than those in Token Ring headers will
1049 not correctly handle source-routed Token Ring packets.
1051 Filter expressions on fields other than those in 802.11 headers will not
1052 correctly handle 802.11 data packets with both To DS and From DS set.
1055 should chase header chain, but at this moment it does not.
1056 `\fBip6 protochain\fP'
1057 is supplied for this behavior. For example, to match IPv6 fragments:
1058 `\fBip6 protochain\fP 44'
1060 Arithmetic expression against transport layer headers, like \fBtcp[0]\fP,
1061 does not work against IPv6 packets.
1062 It only looks at IPv4 packets.