1TCPDUMP(8)                  System Manager's Manual                 TCPDUMP(8)
2
3
4

NAME

6       tcpdump - dump traffic on a network
7

SYNOPSIS

9       tcpdump [ -AbdDefhHIJKlLnNOpqStuUvxX# ] [ -B buffer_size ]
10               [ -c count ] [ --count ] [ -C file_size ]
11               [ -E spi@ipaddr algo:secret,...  ]
12               [ -F file ] [ -G rotate_seconds ] [ -i interface ]
13               [ --immediate-mode ] [ -j tstamp_type ] [ -m module ]
14               [ -M secret ] [ --number ] [ --print ] [ -Q in|out|inout ]
15               [ -r file ] [ -s snaplen ] [ -T type ] [ --version ]
16               [ -V file ] [ -w file ] [ -W filecount ] [ -y datalinktype ]
17               [ -z postrotate-command ] [ -Z user ]
18               [ --time-stamp-precision=tstamp_precision ]
19               [ --micro ] [ --nano ]
20               [ expression ]
21

DESCRIPTION

23       Tcpdump  prints  out a description of the contents of packets on a net‐
24       work interface that match the Boolean expression;  the  description  is
25       preceded  by a time stamp, printed, by default, as hours, minutes, sec‐
26       onds, and fractions of a second since midnight.  It  can  also  be  run
27       with the -w flag, which causes it to save the packet data to a file for
28       later analysis, and/or with the -r flag, which causes it to read from a
29       saved packet file rather than to read packets from a network interface.
30       It can also be run with the -V flag, which causes it to read a list  of
31       saved  packet  files.  In all cases, only packets that match expression
32       will be processed by tcpdump.
33
34       Tcpdump will, if not run with the -c flag, continue  capturing  packets
35       until  it is interrupted by a SIGINT signal (generated, for example, by
36       typing your interrupt character, typically control-C) or a SIGTERM sig‐
37       nal  (typically generated with the kill(1) command); if run with the -c
38       flag, it will capture packets until it is interrupted by  a  SIGINT  or
39       SIGTERM signal or the specified number of packets have been processed.
40
41       When tcpdump finishes capturing packets, it will report counts of:
42
43              packets ``captured'' (this is the number of packets that tcpdump
44              has received and processed);
45
46              packets ``received by filter'' (the meaning of this  depends  on
47              the  OS on which you're running tcpdump, and possibly on the way
48              the OS was configured - if a filter was specified on the command
49              line,  on some OSes it counts packets regardless of whether they
50              were matched by the filter expression and,  even  if  they  were
51              matched  by the filter expression, regardless of whether tcpdump
52              has read and processed them yet, on other OSes  it  counts  only
53              packets that were matched by the filter expression regardless of
54              whether tcpdump has read and processed them yet,  and  on  other
55              OSes  it counts only packets that were matched by the filter ex‐
56              pression and were processed by tcpdump);
57
58              packets ``dropped by kernel'' (this is  the  number  of  packets
59              that  were dropped, due to a lack of buffer space, by the packet
60              capture mechanism in the OS on which tcpdump is running, if  the
61              OS  reports that information to applications; if not, it will be
62              reported as 0).
63
64       On platforms that support the SIGINFO signal, such as  most  BSDs  (in‐
65       cluding macOS) and Digital/Tru64 UNIX, it will report those counts when
66       it receives a SIGINFO signal (generated, for example,  by  typing  your
67       ``status''  character, typically control-T, although on some platforms,
68       such as macOS, the ``status'' character is not set by default,  so  you
69       must  set it with stty(1) in order to use it) and will continue captur‐
70       ing packets. On platforms that do not support the SIGINFO  signal,  the
71       same can be achieved by using the SIGUSR1 signal.
72
73       Using the SIGUSR2 signal along with the -w flag will forcibly flush the
74       packet buffer into the output file.
75
76       Reading packets from a network interface may require that you have spe‐
77       cial  privileges;  see the pcap(3PCAP) man page for details.  Reading a
78       saved packet file doesn't require special privileges.
79

OPTIONS

81       -A     Print each packet (minus its link level header) in ASCII.  Handy
82              for capturing web pages.
83
84       -b     Print the AS number in BGP packets in ASDOT notation rather than
85              ASPLAIN notation.
86
87       -B buffer_size
88       --buffer-size=buffer_size
89              Set the operating system capture buffer size to buffer_size,  in
90              units of KiB (1024 bytes).
91
92       -c count
93              Exit after receiving count packets.
94
95       --count
96              Print  only  on  stderr  the  packet  count when reading capture
97              file(s) instead of parsing/printing the packets. If a filter  is
98              specified  on the command line, tcpdump counts only packets that
99              were matched by the filter expression.
100
101       -C file_size
102              Before writing a raw packet to a  savefile,  check  whether  the
103              file  is  currently  larger than file_size and, if so, close the
104              current savefile and open a new one.  Savefiles after the  first
105              savefile  will  have the name specified with the -w flag, with a
106              number after it, starting at 1 and continuing upward.  The units
107              of  file_size  are  millions  of  bytes  (1,000,000  bytes,  not
108              1,048,576 bytes).
109
110              Note that when used with -Z option (enabled by default),  privi‐
111              leges are dropped before opening the first savefile.
112
113       -d     Dump  the compiled packet-matching code in a human readable form
114              to standard output and stop.
115
116              Please mind that although code compilation  is  always  DLT-spe‐
117              cific,  typically  it is impossible (and unnecessary) to specify
118              which DLT to use for the dump because tcpdump  uses  either  the
119              DLT of the input pcap file specified with -r, or the default DLT
120              of the network interface specified with -i,  or  the  particular
121              DLT  of  the  network interface specified with -y and -i respec‐
122              tively. In these cases the dump shows the same exact  code  that
123              would filter the input file or the network interface without -d.
124
125              However, when neither -r nor -i is specified, specifying -d pre‐
126              vents tcpdump from guessing a suitable  network  interface  (see
127              -i).   In this case the DLT defaults to EN10MB and can be set to
128              another valid value manually with -y.
129
130       -dd    Dump packet-matching code as a C program fragment.
131
132       -ddd   Dump packet-matching code as decimal numbers  (preceded  with  a
133              count).
134
135       -D
136       --list-interfaces
137              Print the list of the network interfaces available on the system
138              and on which tcpdump can capture packets.  For each network  in‐
139              terface,  a number and an interface name, possibly followed by a
140              text description of the interface, are printed.   The  interface
141              name  or the number can be supplied to the -i flag to specify an
142              interface on which to capture.
143
144              This can be useful on systems that don't have a command to  list
145              them  (e.g.,  Windows  systems, or UNIX systems lacking ifconfig
146              -a); the number can be useful on Windows 2000 and later systems,
147              where the interface name is a somewhat complex string.
148
149              The  -D  flag will not be supported if tcpdump was built with an
150              older version of libpcap that lacks the  pcap_findalldevs(3PCAP)
151              function.
152
153       -e     Print  the  link-level  header  on  each dump line.  This can be
154              used, for example, to print MAC layer  addresses  for  protocols
155              such as Ethernet and IEEE 802.11.
156
157       -E     Use spi@ipaddr algo:secret for decrypting IPsec ESP packets that
158              are addressed to addr and contain Security Parameter Index value
159              spi. This combination may be repeated with comma or newline sep‐
160              aration.
161
162              Note that setting the secret for IPv4 ESP packets  is  supported
163              at this time.
164
165              Algorithms  may  be  des-cbc,  3des-cbc,  blowfish-cbc, rc3-cbc,
166              cast128-cbc, or none.  The default is des-cbc.  The  ability  to
167              decrypt  packets  is  only  present if tcpdump was compiled with
168              cryptography enabled.
169
170              secret is the ASCII text for ESP secret key.  If preceded by 0x,
171              then a hex value will be read.
172
173              The  option assumes RFC2406 ESP, not RFC1827 ESP.  The option is
174              only for debugging purposes, and the use of this option  with  a
175              true  `secret'  key  is discouraged.  By presenting IPsec secret
176              key onto command line you make it visible to others,  via  ps(1)
177              and other occasions.
178
179              In  addition  to  the  above syntax, the syntax file name may be
180              used to have tcpdump read the provided  file  in.  The  file  is
181              opened  upon receiving the first ESP packet, so any special per‐
182              missions that tcpdump may have been given  should  already  have
183              been given up.
184
185       -f     Print  `foreign' IPv4 addresses numerically rather than symboli‐
186              cally (this option is intended to get around serious brain  dam‐
187              age  in  Sun's NIS server — usually it hangs forever translating
188              non-local internet numbers).
189
190              The test for `foreign' IPv4 addresses is done using the IPv4 ad‐
191              dress  and  netmask  of  the interface on which capture is being
192              done.  If that address or netmask are not available,  available,
193              either  because the interface on which capture is being done has
194              no address or netmask or because the capture is  being  done  on
195              the  Linux  "any"  interface, which can capture on more than one
196              interface, this option will not work correctly.
197
198       -F file
199              Use file as input for the filter expression.  An additional  ex‐
200              pression given on the command line is ignored.
201
202       -G rotate_seconds
203              If specified, rotates the dump file specified with the -w option
204              every rotate_seconds seconds.   Savefiles  will  have  the  name
205              specified by -w which should include a time format as defined by
206              strftime(3).  If no time format is specified, each new file will
207              overwrite  the  previous.   Whenever a generated filename is not
208              unique, tcpdump will overwrite the pre-existing data;  providing
209              a  time specification that is coarser than the capture period is
210              therefore not advised.
211
212              If used in conjunction with the -C option, filenames  will  take
213              the form of `file<count>'.
214
215              Note  that when used with -Z option (enabled by default), privi‐
216              leges are dropped before opening the first savefile.
217
218       -h
219       --help Print the tcpdump and libpcap version  strings,  print  a  usage
220              message, and exit.
221
222       --version
223              Print the tcpdump and libpcap version strings and exit.
224
225       -H     Attempt to detect 802.11s draft mesh headers.
226
227       -i interface
228       --interface=interface
229              Listen,  report the list of link-layer types, report the list of
230              time stamp types, or report the results of  compiling  a  filter
231              expression  on  interface.  If unspecified and if the -d flag is
232              not given, tcpdump searches the system interface  list  for  the
233              lowest  numbered,  configured up interface (excluding loopback),
234              which may turn out to be, for example, ``eth0''.
235
236              On Linux systems with 2.2 or later kernels, an  interface  argu‐
237              ment  of  ``any'' can be used to capture packets from all inter‐
238              faces.  Note that captures on the ``any''  device  will  not  be
239              done in promiscuous mode.
240
241              If  the  -D flag is supported, an interface number as printed by
242              that flag can be used as the interface argument, if no interface
243              on the system has that number as a name.
244
245       -I
246       --monitor-mode
247              Put  the  interface in "monitor mode"; this is supported only on
248              IEEE 802.11 Wi-Fi interfaces, and supported only on some operat‐
249              ing systems.
250
251              Note  that  in  monitor mode the adapter might disassociate from
252              the network with which it's associated, so that you will not  be
253              able to use any wireless networks with that adapter.  This could
254              prevent accessing files on a network server, or  resolving  host
255              names or network addresses, if you are capturing in monitor mode
256              and are not connected to another network with another adapter.
257
258              This flag will affect the output of the -L flag.   If  -I  isn't
259              specified,  only  those  link-layer  types available when not in
260              monitor mode will be shown; if -I is specified, only those link-
261              layer types available when in monitor mode will be shown.
262
263       --immediate-mode
264              Capture  in  "immediate mode".  In this mode, packets are deliv‐
265              ered to tcpdump as  soon  as  they  arrive,  rather  than  being
266              buffered  for  efficiency.   This  is  the default when printing
267              packets rather than saving packets  to  a  ``savefile''  if  the
268              packets are being printed to a terminal rather than to a file or
269              pipe.
270
271       -j tstamp_type
272       --time-stamp-type=tstamp_type
273              Set the time stamp type for the  capture  to  tstamp_type.   The
274              names   to   use   for   the  time  stamp  types  are  given  in
275              pcap-tstamp(7); not all the types listed there will  necessarily
276              be valid for any given interface.
277
278       -J
279       --list-time-stamp-types
280              List  the supported time stamp types for the interface and exit.
281              If the time stamp type cannot be set for the interface, no  time
282              stamp types are listed.
283
284       --time-stamp-precision=tstamp_precision
285              When  capturing, set the time stamp precision for the capture to
286              tstamp_precision.  Note that availability of high precision time
287              stamps  (nanoseconds)  and their actual accuracy is platform and
288              hardware dependent.  Also note that when writing  captures  made
289              with  nanosecond  accuracy  to  a  savefile, the time stamps are
290              written with nanosecond resolution, and the file is written with
291              a  different  magic number, to indicate that the time stamps are
292              in seconds and nanoseconds; not  all  programs  that  read  pcap
293              savefiles will be able to read those captures.
294
295              When  reading  a  savefile, convert time stamps to the precision
296              specified by timestamp_precision, and  display  them  with  that
297              resolution.   If the precision specified is less than the preci‐
298              sion of time stamps in the file, the conversion will lose preci‐
299              sion.
300
301              The  supported  values for timestamp_precision are micro for mi‐
302              crosecond resolution and nano for  nanosecond  resolution.   The
303              default is microsecond resolution.
304
305       --micro
306       --nano Shorthands for --time-stamp-precision=micro or --time-stamp-pre‐
307              cision=nano, adjusting the  time  stamp  precision  accordingly.
308              When  reading  packets  from a savefile, using --micro truncates
309              time stamps if the savefile was created with  nanosecond  preci‐
310              sion.   In  contrast, a savefile created with microsecond preci‐
311              sion will have trailing zeroes added  to  the  time  stamp  when
312              --nano is used.
313
314       -K
315       --dont-verify-checksums
316              Don't attempt to verify IP, TCP, or UDP checksums.  This is use‐
317              ful for interfaces that perform some or all  of  those  checksum
318              calculation  in  hardware; otherwise, all outgoing TCP checksums
319              will be flagged as bad.
320
321       -l     Make stdout line buffered.  Useful if you want to see  the  data
322              while capturing it.  E.g.,
323
324                     tcpdump -l | tee dat
325
326              or
327
328                     tcpdump -l > dat & tail -f dat
329
330              Note  that on Windows,``line buffered'' means ``unbuffered'', so
331              that WinDump will write each character  individually  if  -l  is
332              specified.
333
334              -U is similar to -l in its behavior, but it will cause output to
335              be ``packet-buffered'', so that the output is written to  stdout
336              at  the  end of each packet rather than at the end of each line;
337              this is buffered on all platforms, including Windows.
338
339       -L
340       --list-data-link-types
341              List the known data link types for the interface, in the  speci‐
342              fied  mode,  and exit.  The list of known data link types may be
343              dependent on the specified mode; for example, on some platforms,
344              a  Wi-Fi interface might support one set of data link types when
345              not in monitor mode (for example, it  might  support  only  fake
346              Ethernet  headers,  or might support 802.11 headers but not sup‐
347              port 802.11 headers with radio information) and another  set  of
348              data link types when in monitor mode (for example, it might sup‐
349              port 802.11 headers, or 802.11 headers with  radio  information,
350              only in monitor mode).
351
352       -m module
353              Load  SMI  MIB module definitions from file module.  This option
354              can be used several times to load several MIB modules into  tcp‐
355              dump.
356
357       -M secret
358              Use  secret  as a shared secret for validating the digests found
359              in TCP segments with the TCP-MD5 option (RFC 2385), if present.
360
361       -n     Don't convert host addresses to names.   This  can  be  used  to
362              avoid DNS lookups.
363
364       -nn    Don't convert protocol and port numbers etc. to names either.
365
366       -N     Don't  print  domain name qualification of host names.  E.g., if
367              you give this flag then tcpdump will print  ``nic''  instead  of
368              ``nic.ddn.mil''.
369
370       -#
371       --number
372              Print an optional packet number at the beginning of the line.
373
374       -O
375       --no-optimize
376              Do  not  run the packet-matching code optimizer.  This is useful
377              only if you suspect a bug in the optimizer.
378
379       -p
380       --no-promiscuous-mode
381              Don't put the interface into promiscuous mode.   Note  that  the
382              interface  might  be  in promiscuous mode for some other reason;
383              hence, `-p' cannot be used as an abbreviation  for  `ether  host
384              {local-hw-addr} or ether broadcast'.
385
386       --print
387              Print  parsed  packet  output, even if the raw packets are being
388              saved to a file with the -w flag.
389
390       -Q direction
391       --direction=direction
392              Choose send/receive direction direction for which packets should
393              be  captured.  Possible  values are `in', `out' and `inout'. Not
394              available on all platforms.
395
396       -q     Quick (quiet?) output.  Print less protocol information so  out‐
397              put lines are shorter.
398
399       -r file
400              Read  packets from file (which was created with the -w option or
401              by other tools that write pcap or pcapng files).  Standard input
402              is used if file is ``-''.
403
404       -S
405       --absolute-tcp-sequence-numbers
406              Print absolute, rather than relative, TCP sequence numbers.
407
408       -s snaplen
409       --snapshot-length=snaplen
410              Snarf snaplen bytes of data from each packet rather than the de‐
411              fault of 262144 bytes.  Packets truncated because of  a  limited
412              snapshot  are  indicated  in the output with ``[|proto]'', where
413              proto is the name of the protocol level at which the  truncation
414              has occurred.
415
416              Note  that  taking larger snapshots both increases the amount of
417              time it takes to process packets and, effectively, decreases the
418              amount  of packet buffering.  This may cause packets to be lost.
419              Note also that taking smaller snapshots will discard  data  from
420              protocols  above  the  transport  layer, which loses information
421              that may be important.  NFS and AFS requests  and  replies,  for
422              example,  are very large, and much of the detail won't be avail‐
423              able if a too-short snapshot length is selected.
424
425              If you need to reduce the snapshot size below the  default,  you
426              should  limit  snaplen  to the smallest number that will capture
427              the protocol information you're interested in.  Setting  snaplen
428              to 0 sets it to the default of 262144, for backwards compatibil‐
429              ity with recent older versions of tcpdump.
430
431       -T type
432              Force packets selected by "expression"  to  be  interpreted  the
433              specified  type.   Currently known types are aodv (Ad-hoc On-de‐
434              mand Distance Vector protocol), carp (Common Address  Redundancy
435              Protocol),  cnfp  (Cisco  NetFlow protocol), domain (Domain Name
436              System), lmp (Link Management Protocol), pgm (Pragmatic  General
437              Multicast), pgm_zmtp1 (ZMTP/1.0 inside PGM/EPGM), ptp (Precision
438              Time Protocol), radius (RADIUS), resp (REdis Serialization  Pro‐
439              tocol),  rpc  (Remote  Procedure Call), rtcp (Real-Time Applica‐
440              tions control protocol), rtp (Real-Time Applications  protocol),
441              snmp  (Simple  Network  Management  Protocol), someip (SOME/IP),
442              tftp (Trivial File Transfer Protocol), vat (Visual Audio  Tool),
443              vxlan  (Virtual  eXtensible Local Area Network), wb (distributed
444              White Board) and zmtp1 (ZeroMQ Message Transport Protocol 1.0).
445
446              Note that the pgm type above affects  UDP  interpretation  only,
447              the  native  PGM is always recognised as IP protocol 113 regard‐
448              less. UDP-encapsulated PGM is often called "EPGM" or "PGM/UDP".
449
450              Note that the pgm_zmtp1 type  above  affects  interpretation  of
451              both  native PGM and UDP at once. During the native PGM decoding
452              the application data of an ODATA/RDATA packet would  be  decoded
453              as  a  ZeroMQ datagram with ZMTP/1.0 frames.  During the UDP de‐
454              coding in addition to that any UDP packet would be treated as an
455              encapsulated PGM packet.
456
457       -t     Don't print a timestamp on each dump line.
458
459       -tt    Print the timestamp, as seconds since January 1, 1970, 00:00:00,
460              UTC, and fractions of a second since that  time,  on  each  dump
461              line.
462
463       -ttt   Print a delta (microsecond or nanosecond resolution depending on
464              the --time-stamp-precision option) between current and  previous
465              line on each dump line.  The default is microsecond resolution.
466
467       -tttt  Print  a timestamp, as hours, minutes, seconds, and fractions of
468              a second since midnight, preceded by  the  date,  on  each  dump
469              line.
470
471       -ttttt Print a delta (microsecond or nanosecond resolution depending on
472              the --time-stamp-precision option)  between  current  and  first
473              line on each dump line.  The default is microsecond resolution.
474
475       -u     Print undecoded NFS handles.
476
477       -U
478       --packet-buffered
479              If the -w option is not specified, or if it is specified but the
480              --print flag is also specified, make the printed  packet  output
481              ``packet-buffered''; i.e., as the description of the contents of
482              each packet is printed, it will be written to the standard  out‐
483              put,  rather than, when not writing to a terminal, being written
484              only when the output buffer fills.
485
486              If the -w option is specified, make the saved raw packet  output
487              ``packet-buffered'';  i.e.,  as each packet is saved, it will be
488              written to the output file, rather than being written only  when
489              the output buffer fills.
490
491              The  -U  flag will not be supported if tcpdump was built with an
492              older version of libpcap that lacks  the  pcap_dump_flush(3PCAP)
493              function.
494
495       -v     When  parsing and printing, produce (slightly more) verbose out‐
496              put.  For example,  the  time  to  live,  identification,  total
497              length  and  options  in an IP packet are printed.  Also enables
498              additional packet integrity checks such as verifying the IP  and
499              ICMP header checksum.
500
501              When  writing  to a file with the -w option and at the same time
502              not reading from a file with the -r option,  report  to  stderr,
503              once  per  second,  the  number of packets captured. In Solaris,
504              FreeBSD and possibly other operating systems this  periodic  up‐
505              date  currently  can cause loss of captured packets on their way
506              from the kernel to tcpdump.
507
508       -vv    Even more verbose output.  For example,  additional  fields  are
509              printed  from  NFS  reply packets, and SMB packets are fully de‐
510              coded.
511
512       -vvv   Even more verbose output.  For example, telnet SB ... SE options
513              are  printed in full.  With -X Telnet options are printed in hex
514              as well.
515
516       -V file
517              Read a list of filenames from file. Standard input  is  used  if
518              file is ``-''.
519
520       -w file
521              Write  the  raw packets to file rather than parsing and printing
522              them out.  They can later be printed with the -r option.   Stan‐
523              dard output is used if file is ``-''.
524
525              This  output will be buffered if written to a file or pipe, so a
526              program reading from the file or pipe may not see packets for an
527              arbitrary  amount  of  time after they are received.  Use the -U
528              flag to cause packets to be written as  soon  as  they  are  re‐
529              ceived.
530
531              The  MIME  type application/vnd.tcpdump.pcap has been registered
532              with IANA for pcap files. The filename extension  .pcap  appears
533              to  be  the most commonly used along with .cap and .dmp. Tcpdump
534              itself doesn't check the extension when  reading  capture  files
535              and  doesn't  add  an extension when writing them (it uses magic
536              numbers in the file header  instead).  However,  many  operating
537              systems and applications will use the extension if it is present
538              and adding one (e.g. .pcap) is recommended.
539
540              See pcap-savefile(5) for a description of the file format.
541
542       -W filecount
543              Used in conjunction with the -C option, this will limit the num‐
544              ber  of  files  created to the specified number, and begin over‐
545              writing files from the beginning,  thus  creating  a  'rotating'
546              buffer.  In addition, it will name the files with enough leading
547              0s to support the maximum number of files, allowing them to sort
548              correctly.
549
550              Used in conjunction with the -G option, this will limit the num‐
551              ber of rotated dump files that get created, exiting with  status
552              0 when reaching the limit.
553
554              If  used  in conjunction with both -C and -G, the -W option will
555              currently be ignored, and will only affect the file name.
556
557       -x     When parsing and printing, in addition to printing  the  headers
558              of  each  packet,  print the data of each packet (minus its link
559              level header) in hex.  The  smaller  of  the  entire  packet  or
560              snaplen  bytes  will  be  printed.  Note that this is the entire
561              link-layer packet, so for link layers that pad (e.g.  Ethernet),
562              the  padding  bytes  will  also be printed when the higher layer
563              packet is shorter than the required padding.  In the current im‐
564              plementation  this  flag  may have the same effect as -xx if the
565              packet is truncated.
566
567       -xx    When parsing and printing, in addition to printing  the  headers
568              of  each  packet,  print  the data of each packet, including its
569              link level header, in hex.
570
571       -X     When parsing and printing, in addition to printing  the  headers
572              of  each  packet,  print the data of each packet (minus its link
573              level header)  in  hex  and  ASCII.   This  is  very  handy  for
574              analysing  new  protocols.   In  the current implementation this
575              flag may have the same effect as -XX if the packet is truncated.
576
577       -XX    When parsing and printing, in addition to printing  the  headers
578              of  each  packet,  print  the data of each packet, including its
579              link level header, in hex and ASCII.
580
581       -y datalinktype
582       --linktype=datalinktype
583              Set the data link type to use while capturing packets  (see  -L)
584              or  just  compiling and dumping packet-matching code (see -d) to
585              datalinktype.
586
587       -z postrotate-command
588              Used in conjunction with the -C or -G options,  this  will  make
589              tcpdump  run " postrotate-command file " where file is the save‐
590              file being closed after each rotation. For  example,  specifying
591              -z  gzip  or  -z bzip2 will compress each savefile using gzip or
592              bzip2.
593
594              Note that tcpdump will run the command in parallel to  the  cap‐
595              ture, using the lowest priority so that this doesn't disturb the
596              capture process.
597
598              And in case you would like to use a command  that  itself  takes
599              flags  or  different  arguments,  you  can  always write a shell
600              script that will take the savefile name as  the  only  argument,
601              make  the flags & arguments arrangements and execute the command
602              that you want.
603
604       -Z user
605       --relinquish-privileges=user
606              If tcpdump is running as root, after opening the capture  device
607              or  input savefile, but before opening any savefiles for output,
608              change the user ID to user and the group ID to the primary group
609              of user.
610
611              This  behavior  is  enabled  by default (-Z tcpdump), and can be
612              disabled by -Z root.
613
614
615        expression
616              selects which packets will  be  dumped.   If  no  expression  is
617              given,  all  packets on the net will be dumped.  Otherwise, only
618              packets for which expression is `true' will be dumped.
619
620              For the expression syntax, see pcap-filter(7).
621
622              The expression argument can be passed to  tcpdump  as  either  a
623              single Shell argument, or as multiple Shell arguments, whichever
624              is more convenient.  Generally, if the expression contains Shell
625              metacharacters,  such  as  backslashes  used  to escape protocol
626              names, it is easier to pass it  as  a  single,  quoted  argument
627              rather  than to escape the Shell metacharacters.  Multiple argu‐
628              ments are concatenated with spaces before being parsed.
629

EXAMPLES

631       To print all packets arriving at or departing from sundown:
632              tcpdump host sundown
633
634       To print traffic between helios and either hot or ace:
635              tcpdump host helios and \( hot or ace \)
636
637       To print all IP packets between ace and any host except helios:
638              tcpdump ip host ace and not helios
639
640       To print all traffic between local hosts and hosts at Berkeley:
641              tcpdump net ucb-ether
642
643       To print all ftp traffic through internet gateway snup: (note that  the
644       expression  is  quoted to prevent the shell from (mis-)interpreting the
645       parentheses):
646              tcpdump 'gateway snup and (port ftp or ftp-data)'
647
648       To print traffic neither sourced from nor destined for local hosts  (if
649       you gateway to one other net, this stuff should never make it onto your
650       local net).
651              tcpdump ip and not net localnet
652
653       To print the start and end packets (the SYN and FIN  packets)  of  each
654       TCP conversation that involves a non-local host.
655              tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net localnet'
656
657       To print the TCP packets with flags RST and ACK both set.  (i.e. select
658       only the RST and ACK flags in the flags field, and  if  the  result  is
659       "RST and ACK both set", match)
660              tcpdump 'tcp[tcpflags] & (tcp-rst|tcp-ack) == (tcp-rst|tcp-ack)'
661
662       To  print  all  IPv4  HTTP packets to and from port 80, i.e. print only
663       packets that contain data, not, for example, SYN and  FIN  packets  and
664       ACK-only packets.  (IPv6 is left as an exercise for the reader.)
665              tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
666
667       To print IP packets longer than 576 bytes sent through gateway snup:
668              tcpdump 'gateway snup and ip[2:2] > 576'
669
670       To  print IP broadcast or multicast packets that were not sent via Eth‐
671       ernet broadcast or multicast:
672              tcpdump 'ether[0] & 1 = 0 and ip[16] >= 224'
673
674       To print all ICMP packets that are not echo requests/replies (i.e., not
675       ping packets):
676              tcpdump 'icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply'
677

OUTPUT FORMAT

679       The  output  of  tcpdump  is protocol dependent.  The following gives a
680       brief description and examples of most of the formats.
681
682       Timestamps
683
684       By default, all output lines are preceded by a  timestamp.   The  time‐
685       stamp is the current clock time in the form
686              hh:mm:ss.frac
687       and  is  as accurate as the kernel's clock.  The timestamp reflects the
688       time the kernel applied a time stamp to the packet.  No attempt is made
689       to account for the time lag between when the network interface finished
690       receiving the packet from the network and when  the  kernel  applied  a
691       time  stamp  to the packet; that time lag could include a delay between
692       the time when the network interface finished receiving  a  packet  from
693       the  network and the time when an interrupt was delivered to the kernel
694       to get it to read the packet and a delay between the time when the ker‐
695       nel  serviced the `new packet' interrupt and the time when it applied a
696       time stamp to the packet.
697
698       Link Level Headers
699
700       If the '-e' option is given, the link level header is printed out.   On
701       Ethernets,  the  source and destination addresses, protocol, and packet
702       length are printed.
703
704       On FDDI networks, the  '-e' option causes tcpdump to print  the  `frame
705       control'  field,   the source and destination addresses, and the packet
706       length.  (The `frame control' field governs the interpretation  of  the
707       rest  of the packet.  Normal packets (such as those containing IP data‐
708       grams) are `async' packets, with a priority value between 0 and 7;  for
709       example,  `async4'.  Such packets are assumed to contain an 802.2 Logi‐
710       cal Link Control (LLC) packet; the LLC header is printed if it  is  not
711       an ISO datagram or a so-called SNAP packet.
712
713       On  Token  Ring  networks,  the '-e' option causes tcpdump to print the
714       `access control' and `frame control' fields, the source and destination
715       addresses, and the packet length.  As on FDDI networks, packets are as‐
716       sumed to contain an LLC packet.  Regardless of whether the '-e'  option
717       is  specified  or  not,  the  source routing information is printed for
718       source-routed packets.
719
720       On 802.11 networks, the '-e' option causes tcpdump to print the  `frame
721       control'  fields,  all  of  the addresses in the 802.11 header, and the
722       packet length.  As on FDDI networks, packets are assumed to contain  an
723       LLC packet.
724
725       (N.B.: The following description assumes familiarity with the SLIP com‐
726       pression algorithm described in RFC-1144.)
727
728       On SLIP links, a direction indicator (``I'' for inbound, ``O'' for out‐
729       bound),  packet type, and compression information are printed out.  The
730       packet type is printed first.  The three types are ip, utcp, and  ctcp.
731       No  further  link information is printed for ip packets.  For TCP pack‐
732       ets, the connection identifier is printed following the type.   If  the
733       packet  is  compressed, its encoded header is printed out.  The special
734       cases are printed out as *S+n and *SA+n, where n is the amount by which
735       the sequence number (or sequence number and ack) has changed.  If it is
736       not a special case, zero or more changes are printed.  A change is  in‐
737       dicated  by  U  (urgent pointer), W (window), A (ack), S (sequence num‐
738       ber), and I (packet ID), followed by a delta (+n or -n), or a new value
739       (=n).   Finally, the amount of data in the packet and compressed header
740       length are printed.
741
742       For example, the  following  line  shows  an  outbound  compressed  TCP
743       packet,  with an implicit connection identifier; the ack has changed by
744       6, the sequence number by 49, and the packet ID by 6; there are 3 bytes
745       of data and 6 bytes of compressed header:
746              O ctcp * A+6 S+49 I+6 3 (6)
747
748       ARP/RARP Packets
749
750       ARP/RARP  output shows the type of request and its arguments.  The for‐
751       mat is intended to be self explanatory.  Here is a short  sample  taken
752       from the start of an `rlogin' from host rtsg to host csam:
753              arp who-has csam tell rtsg
754              arp reply csam is-at CSAM
755       The  first line says that rtsg sent an ARP packet asking for the Ether‐
756       net address of internet host csam.  Csam replies with its Ethernet  ad‐
757       dress (in this example, Ethernet addresses are in caps and internet ad‐
758       dresses in lower case).
759
760       This would look less redundant if we had done tcpdump -n:
761              arp who-has 128.3.254.6 tell 128.3.254.68
762              arp reply 128.3.254.6 is-at 02:07:01:00:01:c4
763
764       If we had done tcpdump -e, the fact that the first packet is  broadcast
765       and the second is point-to-point would be visible:
766              RTSG Broadcast 0806  64: arp who-has csam tell rtsg
767              CSAM RTSG 0806  64: arp reply csam is-at CSAM
768       For the first packet this says the Ethernet source address is RTSG, the
769       destination is the Ethernet broadcast address, the type field contained
770       hex 0806 (type ETHER_ARP) and the total length was 64 bytes.
771
772       IPv4 Packets
773
774       If  the link-layer header is not being printed, for IPv4 packets, IP is
775       printed after the time stamp.
776
777       If the -v flag is specified, information from the IPv4 header is  shown
778       in parentheses after the IP or the link-layer header.  The general for‐
779       mat of this information is:
780              tos tos, ttl ttl, id id, offset offset, flags [flags], proto proto, length length, options (options)
781       tos is the type of service field; if the ECN bits are  non-zero,  those
782       are  reported as ECT(1), ECT(0), or CE.  ttl is the time-to-live; it is
783       not reported if it is zero.  id is the IP identification field.  offset
784       is  the  fragment offset field; it is printed whether this is part of a
785       fragmented datagram or not.  flags are the MF and DF flags;  +  is  re‐
786       ported  if  MF  is set, and DF is reported if F is set.  If neither are
787       set, . is reported.  proto is the protocol ID field.  length is the to‐
788       tal length field.  options are the IP options, if any.
789
790       Next,  for TCP and UDP packets, the source and destination IP addresses
791       and TCP or UDP ports, with a dot between each IP address and its corre‐
792       sponding port, will be printed, with a > separating the source and des‐
793       tination.  For other protocols, the addresses will be printed, with a >
794       separating  the source and destination.  Higher level protocol informa‐
795       tion, if any, will be printed after that.
796
797       For fragmented IP datagrams, the first  fragment  contains  the  higher
798       level  protocol  header;  fragments  after  the first contain no higher
799       level protocol header.  Fragmentation information will be printed  only
800       with the -v flag, in the IP header information, as described above.
801
802       TCP Packets
803
804       (N.B.:The following description assumes familiarity with the TCP proto‐
805       col described in RFC-793.  If you are not familiar with  the  protocol,
806       this description will not be of much use to you.)
807
808       The general format of a TCP protocol line is:
809              src > dst: Flags [tcpflags], seq data-seqno, ack ackno, win window, urg urgent, options [opts], length len
810       Src  and  dst  are  the  source and destination IP addresses and ports.
811       Tcpflags are some combination of S (SYN), F (FIN), P (PUSH), R (RST), U
812       (URG),  W  (ECN  CWR), E (ECN-Echo) or `.' (ACK), or `none' if no flags
813       are set.  Data-seqno describes the portion of sequence space covered by
814       the  data in this packet (see example below).  Ackno is sequence number
815       of the next data expected the other direction on this connection.  Win‐
816       dow  is the number of bytes of receive buffer space available the other
817       direction on this connection.  Urg indicates there is `urgent' data  in
818       the  packet.  Opts are TCP options (e.g., mss 1024).  Len is the length
819       of payload data.
820
821       Iptype, Src, dst, and flags are always present.  The other  fields  de‐
822       pend on the contents of the packet's TCP protocol header and are output
823       only if appropriate.
824
825       Here is the opening portion of an rlogin from host rtsg to host csam.
826              IP rtsg.1023 > csam.login: Flags [S], seq 768512:768512, win 4096, opts [mss 1024]
827              IP csam.login > rtsg.1023: Flags [S.], seq, 947648:947648, ack 768513, win 4096, opts [mss 1024]
828              IP rtsg.1023 > csam.login: Flags [.], ack 1, win 4096
829              IP rtsg.1023 > csam.login: Flags [P.], seq 1:2, ack 1, win 4096, length 1
830              IP csam.login > rtsg.1023: Flags [.], ack 2, win 4096
831              IP rtsg.1023 > csam.login: Flags [P.], seq 2:21, ack 1, win 4096, length 19
832              IP csam.login > rtsg.1023: Flags [P.], seq 1:2, ack 21, win 4077, length 1
833              IP csam.login > rtsg.1023: Flags [P.], seq 2:3, ack 21, win 4077, urg 1, length 1
834              IP csam.login > rtsg.1023: Flags [P.], seq 3:4, ack 21, win 4077, urg 1, length 1
835       The first line says that TCP port 1023 on rtsg sent a  packet  to  port
836       login  on csam.  The S indicates that the SYN flag was set.  The packet
837       sequence number was 768512 and it contained no data.  (The notation  is
838       `first:last'  which means `sequence numbers first up to but not includ‐
839       ing last'.)  There was no piggy-backed ACK, the available receive  win‐
840       dow  was  4096 bytes and there was a max-segment-size option requesting
841       an MSS of 1024 bytes.
842
843       Csam replies with a similar packet except it  includes  a  piggy-backed
844       ACK  for rtsg's SYN.  Rtsg then ACKs csam's SYN.  The `.' means the ACK
845       flag was set.  The packet contained no data so there  is  no  data  se‐
846       quence  number or length.  Note that the ACK sequence number is a small
847       integer (1).  The first time tcpdump  sees  a  TCP  `conversation',  it
848       prints  the  sequence number from the packet.  On subsequent packets of
849       the conversation, the difference between the current packet's  sequence
850       number  and  this  initial sequence number is printed.  This means that
851       sequence numbers after the first can be interpreted  as  relative  byte
852       positions  in  the conversation's data stream (with the first data byte
853       each direction being `1').  `-S' will override  this  feature,  causing
854       the original sequence numbers to be output.
855
856       On  the  6th line, rtsg sends csam 19 bytes of data (bytes 2 through 20
857       in the rtsg → csam side of the conversation).  The PUSH flag is set  in
858       the packet.  On the 7th line, csam says it's received data sent by rtsg
859       up to but not including byte 21.  Most of this data is apparently  sit‐
860       ting  in  the  socket  buffer since csam's receive window has gotten 19
861       bytes smaller.  Csam also sends one  byte  of  data  to  rtsg  in  this
862       packet.   On  the  8th  and  9th lines, csam sends two bytes of urgent,
863       pushed data to rtsg.
864
865       If the snapshot was small enough that tcpdump didn't capture  the  full
866       TCP  header, it interprets as much of the header as it can and then re‐
867       ports ``[|tcp]'' to indicate the remainder could  not  be  interpreted.
868       If  the header contains a bogus option (one with a length that's either
869       too small or beyond the end of  the  header),  tcpdump  reports  it  as
870       ``[bad  opt]''  and  does not interpret any further options (since it's
871       impossible to tell where they start).  If the header  length  indicates
872       options  are  present but the IP datagram length is not long enough for
873       the options to actually be there, tcpdump  reports  it  as  ``[bad  hdr
874       length]''.
875
876       Capturing  TCP packets with particular flag combinations (SYN-ACK, URG-
877       ACK, etc.)
878
879       There are 8 bits in the control bits section of the TCP header:
880
881              CWR | ECE | URG | ACK | PSH | RST | SYN | FIN
882
883       Let's assume that we want to watch packets used in establishing  a  TCP
884       connection.   Recall  that  TCP uses a 3-way handshake protocol when it
885       initializes a new connection; the connection sequence  with  regard  to
886       the TCP control bits is
887
888              1) Caller sends SYN
889              2) Recipient responds with SYN, ACK
890              3) Caller sends ACK
891
892       Now  we're  interested  in capturing packets that have only the SYN bit
893       set (Step 1).  Note that we don't want packets from step  2  (SYN-ACK),
894       just  a plain initial SYN.  What we need is a correct filter expression
895       for tcpdump.
896
897       Recall the structure of a TCP header without options:
898
899        0                            15                              31
900       -----------------------------------------------------------------
901       |          source port          |       destination port        |
902       -----------------------------------------------------------------
903       |                        sequence number                        |
904       -----------------------------------------------------------------
905       |                     acknowledgment number                     |
906       -----------------------------------------------------------------
907       |  HL   | rsvd  |C|E|U|A|P|R|S|F|        window size            |
908       -----------------------------------------------------------------
909       |         TCP checksum          |       urgent pointer          |
910       -----------------------------------------------------------------
911
912       A TCP header usually holds  20  octets  of  data,  unless  options  are
913       present.  The first line of the graph contains octets 0 - 3, the second
914       line shows octets 4 - 7 etc.
915
916       Starting to count with 0, the relevant TCP control bits  are  contained
917       in octet 13:
918
919        0             7|             15|             23|             31
920       ----------------|---------------|---------------|----------------
921       |  HL   | rsvd  |C|E|U|A|P|R|S|F|        window size            |
922       ----------------|---------------|---------------|----------------
923       |               |  13th octet   |               |               |
924
925       Let's have a closer look at octet no. 13:
926
927                       |               |
928                       |---------------|
929                       |C|E|U|A|P|R|S|F|
930                       |---------------|
931                       |7   5   3     0|
932
933       These  are the TCP control bits we are interested in.  We have numbered
934       the bits in this octet from 0 to 7, right to left, so the  PSH  bit  is
935       bit number 3, while the URG bit is number 5.
936
937       Recall  that  we  want to capture packets with only SYN set.  Let's see
938       what happens to octet 13 if a TCP datagram arrives with the SYN bit set
939       in its header:
940
941                       |C|E|U|A|P|R|S|F|
942                       |---------------|
943                       |0 0 0 0 0 0 1 0|
944                       |---------------|
945                       |7 6 5 4 3 2 1 0|
946
947       Looking at the control bits section we see that only bit number 1 (SYN)
948       is set.
949
950       Assuming that octet number 13 is an 8-bit unsigned integer  in  network
951       byte order, the binary value of this octet is
952
953              00000010
954
955       and its decimal representation is
956
957          7     6     5     4     3     2     1     0
958       0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 1*2 + 0*2  =  2
959
960       We're  almost  done,  because  now we know that if only SYN is set, the
961       value of the 13th octet in the TCP header, when interpreted as a  8-bit
962       unsigned integer in network byte order, must be exactly 2.
963
964       This relationship can be expressed as
965              tcp[13] == 2
966
967       We  can use this expression as the filter for tcpdump in order to watch
968       packets which have only SYN set:
969              tcpdump -i xl0 tcp[13] == 2
970
971       The expression says "let the 13th octet of a TCP datagram have the dec‐
972       imal value 2", which is exactly what we want.
973
974       Now,  let's  assume  that  we need to capture SYN packets, but we don't
975       care if ACK or any other TCP control bit  is  set  at  the  same  time.
976       Let's see what happens to octet 13 when a TCP datagram with SYN-ACK set
977       arrives:
978
979            |C|E|U|A|P|R|S|F|
980            |---------------|
981            |0 0 0 1 0 0 1 0|
982            |---------------|
983            |7 6 5 4 3 2 1 0|
984
985       Now bits 1 and 4 are set in the 13th octet.  The binary value of  octet
986       13 is
987
988                   00010010
989
990       which translates to decimal
991
992          7     6     5     4     3     2     1     0
993       0*2 + 0*2 + 0*2 + 1*2 + 0*2 + 0*2 + 1*2 + 0*2   = 18
994
995       Now we can't just use 'tcp[13] == 18' in the tcpdump filter expression,
996       because that would select only those packets that have SYN-ACK set, but
997       not those with only SYN set.  Remember that we don't care if ACK or any
998       other control bit is set as long as SYN is set.
999
1000       In order to achieve our goal, we need to logically AND the binary value
1001       of  octet  13  with  some other value to preserve the SYN bit.  We know
1002       that we want SYN to be set in any case,  so  we'll  logically  AND  the
1003       value in the 13th octet with the binary value of a SYN:
1004
1005                 00010010 SYN-ACK              00000010 SYN
1006            AND  00000010 (we want SYN)   AND  00000010 (we want SYN)
1007                 --------                      --------
1008            =    00000010                 =    00000010
1009
1010       We  see  that  this  AND  operation delivers the same result regardless
1011       whether ACK or another TCP control bit is set.  The decimal representa‐
1012       tion of the AND value as well as the result of this operation is 2 (bi‐
1013       nary 00000010), so we know that for packets with SYN set the  following
1014       relation must hold true:
1015
1016              ( ( value of octet 13 ) AND ( 2 ) ) == ( 2 )
1017
1018       This points us to the tcpdump filter expression
1019                   tcpdump -i xl0 'tcp[13] & 2 == 2'
1020
1021       Some  offsets and field values may be expressed as names rather than as
1022       numeric values. For example tcp[13] may be replaced with tcp[tcpflags].
1023       The  following  TCP flag field values are also available: tcp-fin, tcp-
1024       syn, tcp-rst, tcp-push, tcp-ack, tcp-urg.
1025
1026       This can be demonstrated as:
1027                   tcpdump -i xl0 'tcp[tcpflags] & tcp-push != 0'
1028
1029       Note that you should use single quotes or a backslash in the expression
1030       to hide the AND ('&') special character from the shell.
1031
1032       UDP Packets
1033
1034       UDP format is illustrated by this rwho packet:
1035              actinide.who > broadcast.who: udp 84
1036       This  says  that  port who on host actinide sent a UDP datagram to port
1037       who on host broadcast, the Internet broadcast address.  The packet con‐
1038       tained 84 bytes of user data.
1039
1040       Some  UDP  services are recognized (from the source or destination port
1041       number) and the higher level protocol information printed.  In particu‐
1042       lar,  Domain  Name  service  requests (RFC-1034/1035) and Sun RPC calls
1043       (RFC-1050) to NFS.
1044
1045       TCP or UDP Name Server Requests
1046
1047       (N.B.:The following description assumes  familiarity  with  the  Domain
1048       Service  protocol  described in RFC-1035.  If you are not familiar with
1049       the protocol, the following description will appear to  be  written  in
1050       Greek.)
1051
1052       Name server requests are formatted as
1053              src > dst: id op? flags qtype qclass name (len)
1054              h2opolo.1538 > helios.domain: 3+ A? ucbvax.berkeley.edu. (37)
1055       Host  h2opolo  asked  the domain server on helios for an address record
1056       (qtype=A) associated with the name ucbvax.berkeley.edu.  The  query  id
1057       was  `3'.   The  `+' indicates the recursion desired flag was set.  The
1058       query length was 37 bytes, excluding the TCP or  UDP  and  IP  protocol
1059       headers.   The  query  operation  was  the normal one, Query, so the op
1060       field was omitted.  If the op had been anything  else,  it  would  have
1061       been  printed  between  the `3' and the `+'.  Similarly, the qclass was
1062       the normal one, C_IN, and omitted.  Any other qclass  would  have  been
1063       printed immediately after the `A'.
1064
1065       A  few anomalies are checked and may result in extra fields enclosed in
1066       square brackets:  If a query contains an answer, authority  records  or
1067       additional records section, ancount, nscount, or arcount are printed as
1068       `[na]', `[nn]' or  `[nau]' where n is the appropriate count.  If any of
1069       the  response  bits  are  set  (AA, RA or rcode) or any of the `must be
1070       zero' bits are set in bytes two and three, `[b2&3=x]' is printed, where
1071       x is the hex value of header bytes two and three.
1072
1073       TCP or UDP Name Server Responses
1074
1075       Name server responses are formatted as
1076              src > dst:  id op rcode flags a/n/au type class data (len)
1077              helios.domain > h2opolo.1538: 3 3/3/7 A 128.32.137.3 (273)
1078              helios.domain > h2opolo.1537: 2 NXDomain* 0/1/0 (97)
1079       In the first example, helios responds to query id 3 from h2opolo with 3
1080       answer records, 3 name server records and 7  additional  records.   The
1081       first  answer  record  is type A (address) and its data is internet ad‐
1082       dress 128.32.137.3.  The total size of the response was 273 bytes,  ex‐
1083       cluding  TCP  or  UDP and IP headers.  The op (Query) and response code
1084       (NoError) were omitted, as was the class (C_IN) of the A record.
1085
1086       In the second example, helios responds to query 2 with a response  code
1087       of  non-existent domain (NXDomain) with no answers, one name server and
1088       no authority records.  The `*' indicates that the authoritative  answer
1089       bit  was set.  Since there were no answers, no type, class or data were
1090       printed.
1091
1092       Other flag characters that might appear are `-'  (recursion  available,
1093       RA,  not  set) and `|' (truncated message, TC, set).  If the `question'
1094       section doesn't contain exactly one entry, `[nq]' is printed.
1095
1096       SMB/CIFS decoding
1097
1098       tcpdump now includes fairly extensive SMB/CIFS/NBT decoding for data on
1099       UDP/137,  UDP/138 and TCP/139.  Some primitive decoding of IPX and Net‐
1100       BEUI SMB data is also done.
1101
1102       By default a fairly minimal decode is done, with a much  more  detailed
1103       decode  done if -v is used.  Be warned that with -v a single SMB packet
1104       may take up a page or more, so only use -v if you really want  all  the
1105       gory details.
1106
1107       For  information on SMB packet formats and what all the fields mean see
1108       https://download.samba.org/pub/samba/specs/ and other online resources.
1109       The SMB patches were written by Andrew Tridgell (tridge@samba.org).
1110
1111       NFS Requests and Replies
1112
1113       Sun NFS (Network File System) requests and replies are printed as:
1114              src.sport > dst.nfs: NFS request xid xid len op args
1115              src.nfs > dst.dport: NFS reply xid xid reply stat len op results
1116              sushi.1023 > wrl.nfs: NFS request xid 26377
1117                   112 readlink fh 21,24/10.73165
1118              wrl.nfs > sushi.1023: NFS reply xid 26377
1119                   reply ok 40 readlink "../var"
1120              sushi.1022 > wrl.nfs: NFS request xid 8219
1121                   144 lookup fh 9,74/4096.6878 "xcolors"
1122              wrl.nfs > sushi.1022: NFS reply xid 8219
1123                   reply ok 128 lookup fh 9,74/4134.3150
1124       In the first line, host sushi sends a transaction with id 26377 to wrl.
1125       The request was 112 bytes, excluding the UDP and IP headers.  The oper‐
1126       ation  was  a  readlink  (read  symbolic  link)  on  file  handle  (fh)
1127       21,24/10.731657119.  (If one is lucky, as in this case, the file handle
1128       can be interpreted as a major,minor device number pair, followed by the
1129       inode number and generation number.) In the second  line,  wrl  replies
1130       `ok' with the same transaction id and the contents of the link.
1131
1132       In  the  third  line,  sushi  asks  (using a new transaction id) wrl to
1133       lookup the name `xcolors' in  directory  file  9,74/4096.6878.  In  the
1134       fourth line, wrl sends a reply with the respective transaction id.
1135
1136       Note  that  the data printed depends on the operation type.  The format
1137       is intended to be self explanatory if read in conjunction with  an  NFS
1138       protocol  spec.   Also  note that older versions of tcpdump printed NFS
1139       packets in a slightly different format: the transaction id (xid)  would
1140       be printed instead of the non-NFS port number of the packet.
1141
1142       If  the  -v (verbose) flag is given, additional information is printed.
1143       For example:
1144              sushi.1023 > wrl.nfs: NFS request xid 79658
1145                   148 read fh 21,11/12.195 8192 bytes @ 24576
1146              wrl.nfs > sushi.1023: NFS reply xid 79658
1147                   reply ok 1472 read REG 100664 ids 417/0 sz 29388
1148       (-v also prints the  IP  header  TTL,  ID,  length,  and  fragmentation
1149       fields, which have been omitted from this example.)  In the first line,
1150       sushi asks wrl to read 8192 bytes from file 21,11/12.195, at byte  off‐
1151       set  24576.   Wrl  replies `ok'; the packet shown on the second line is
1152       the first fragment of the reply, and hence is only 1472 bytes long (the
1153       other bytes will follow in subsequent fragments, but these fragments do
1154       not have NFS or even UDP headers and so might not be printed, depending
1155       on  the filter expression used).  Because the -v flag is given, some of
1156       the file attributes (which are returned in addition to the  file  data)
1157       are  printed:  the file type (``REG'', for regular file), the file mode
1158       (in octal), the UID and GID, and the file size.
1159
1160       If the -v flag is given more than once, even more details are printed.
1161
1162       NFS reply packets do not explicitly identify the  RPC  operation.   In‐
1163       stead,  tcpdump keeps track of ``recent'' requests, and matches them to
1164       the replies using the transaction ID.  If a reply does not closely fol‐
1165       low the corresponding request, it might not be parsable.
1166
1167       AFS Requests and Replies
1168
1169       Transarc AFS (Andrew File System) requests and replies are printed as:
1170
1171              src.sport > dst.dport: rx packet-type
1172              src.sport > dst.dport: rx packet-type service call call-name args
1173              src.sport > dst.dport: rx packet-type service reply call-name args
1174              elvis.7001 > pike.afsfs:
1175                   rx data fs call rename old fid 536876964/1/1 ".newsrc.new"
1176                   new fid 536876964/1/1 ".newsrc"
1177              pike.afsfs > elvis.7001: rx data fs reply rename
1178       In the first line, host elvis sends a RX packet to pike.  This was a RX
1179       data packet to the fs (fileserver) service, and is the start of an  RPC
1180       call.   The  RPC  call  was a rename, with the old directory file id of
1181       536876964/1/1 and an old filename of `.newsrc.new', and a new directory
1182       file  id  of  536876964/1/1  and a new filename of `.newsrc'.  The host
1183       pike responds with a RPC reply to the rename call (which  was  success‐
1184       ful, because it was a data packet and not an abort packet).
1185
1186       In  general,  all AFS RPCs are decoded at least by RPC call name.  Most
1187       AFS RPCs have at least some of the arguments  decoded  (generally  only
1188       the `interesting' arguments, for some definition of interesting).
1189
1190       The  format is intended to be self-describing, but it will probably not
1191       be useful to people who are not familiar with the workings of  AFS  and
1192       RX.
1193
1194       If  the  -v  (verbose) flag is given twice, acknowledgement packets and
1195       additional header information is printed, such as the RX call ID,  call
1196       number, sequence number, serial number, and the RX packet flags.
1197
1198       If  the -v flag is given twice, additional information is printed, such
1199       as the RX call ID, serial number, and the RX packet flags.  The MTU ne‐
1200       gotiation information is also printed from RX ack packets.
1201
1202       If  the -v flag is given three times, the security index and service id
1203       are printed.
1204
1205       Error codes are printed for abort packets, with the exception  of  Ubik
1206       beacon  packets  (because  abort packets are used to signify a yes vote
1207       for the Ubik protocol).
1208
1209       AFS reply packets do not explicitly identify the  RPC  operation.   In‐
1210       stead,  tcpdump keeps track of ``recent'' requests, and matches them to
1211       the replies using the call number and service ID.  If a reply does  not
1212       closely follow the corresponding request, it might not be parsable.
1213
1214
1215       KIP AppleTalk (DDP in UDP)
1216
1217       AppleTalk DDP packets encapsulated in UDP datagrams are de-encapsulated
1218       and dumped as DDP packets (i.e., all the UDP header information is dis‐
1219       carded).   The file /etc/atalk.names is used to translate AppleTalk net
1220       and node numbers to names.  Lines in this file have the form
1221              number    name
1222
1223              1.254          ether
1224              16.1      icsd-net
1225              1.254.110 ace
1226       The first two lines give the names of AppleTalk  networks.   The  third
1227       line  gives the name of a particular host (a host is distinguished from
1228       a net by the 3rd octet in the number -  a  net  number  must  have  two
1229       octets  and a host number must have three octets.)  The number and name
1230       should  be   separated   by   whitespace   (blanks   or   tabs).    The
1231       /etc/atalk.names  file  may contain blank lines or comment lines (lines
1232       starting with a `#').
1233
1234       AppleTalk addresses are printed in the form
1235              net.host.port
1236
1237              144.1.209.2 > icsd-net.112.220
1238              office.2 > icsd-net.112.220
1239              jssmag.149.235 > icsd-net.2
1240       (If the /etc/atalk.names doesn't exist or doesn't contain an entry  for
1241       some AppleTalk host/net number, addresses are printed in numeric form.)
1242       In the first example, NBP (DDP port 2) on net 144.1 node 209 is sending
1243       to  whatever is listening on port 220 of net icsd node 112.  The second
1244       line is the same except the full name of the source node is known (`of‐
1245       fice').   The third line is a send from port 235 on net jssmag node 149
1246       to broadcast on the icsd-net NBP port (note that the broadcast  address
1247       (255)  is indicated by a net name with no host number - for this reason
1248       it's a good  idea  to  keep  node  names  and  net  names  distinct  in
1249       /etc/atalk.names).
1250
1251       NBP  (name  binding  protocol) and ATP (AppleTalk transaction protocol)
1252       packets have their contents interpreted.  Other protocols just dump the
1253       protocol name (or number if no name is registered for the protocol) and
1254       packet size.
1255
1256       NBP packets are formatted like the following examples:
1257              icsd-net.112.220 > jssmag.2: nbp-lkup 190: "=:LaserWriter@*"
1258              jssmag.209.2 > icsd-net.112.220: nbp-reply 190: "RM1140:LaserWriter@*" 250
1259              techpit.2 > icsd-net.112.220: nbp-reply 190: "techpit:LaserWriter@*" 186
1260       The first line is a name lookup request for laserwriters  sent  by  net
1261       icsd  host  112 and broadcast on net jssmag.  The nbp id for the lookup
1262       is 190.  The second line shows a reply for this request (note  that  it
1263       has  the same id) from host jssmag.209 saying that it has a laserwriter
1264       resource named "RM1140" registered on port 250.  The third line is  an‐
1265       other  reply  to  the  same request saying host techpit has laserwriter
1266       "techpit" registered on port 186.
1267
1268       ATP packet formatting is demonstrated by the following example:
1269              jssmag.209.165 > helios.132: atp-req  12266<0-7> 0xae030001
1270              helios.132 > jssmag.209.165: atp-resp 12266:0 (512) 0xae040000
1271              helios.132 > jssmag.209.165: atp-resp 12266:1 (512) 0xae040000
1272              helios.132 > jssmag.209.165: atp-resp 12266:2 (512) 0xae040000
1273              helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000
1274              helios.132 > jssmag.209.165: atp-resp 12266:4 (512) 0xae040000
1275              helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000
1276              helios.132 > jssmag.209.165: atp-resp 12266:6 (512) 0xae040000
1277              helios.132 > jssmag.209.165: atp-resp*12266:7 (512) 0xae040000
1278              jssmag.209.165 > helios.132: atp-req  12266<3,5> 0xae030001
1279              helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000
1280              helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000
1281              jssmag.209.165 > helios.132: atp-rel  12266<0-7> 0xae030001
1282              jssmag.209.133 > helios.132: atp-req* 12267<0-7> 0xae030002
1283       Jssmag.209 initiates transaction id 12266 with host helios by  request‐
1284       ing  up  to  8 packets (the `<0-7>').  The hex number at the end of the
1285       line is the value of the `userdata' field in the request.
1286
1287       Helios responds with 8 512-byte packets.  The  `:digit'  following  the
1288       transaction  id gives the packet sequence number in the transaction and
1289       the number in parens is the amount of data in the packet, excluding the
1290       ATP header.  The `*' on packet 7 indicates that the EOM bit was set.
1291
1292       Jssmag.209  then  requests that packets 3 & 5 be retransmitted.  Helios
1293       resends them then jssmag.209 releases the transaction.   Finally,  jss‐
1294       mag.209  initiates  the next request.  The `*' on the request indicates
1295       that XO (`exactly once') was not set.
1296
1297

SEE ALSO

1299       stty(1),    pcap(3PCAP),     bpf(4),     nit(4P),     pcap-savefile(5),
1300       pcap-filter(7), pcap-tstamp(7)
1301
1302              https://www.iana.org/assignments/media-types/applica
1303              tion/vnd.tcpdump.pcap
1304

AUTHORS

1306       The original authors are:
1307
1308       Van Jacobson, Craig Leres and  Steven  McCanne,  all  of  the  Lawrence
1309       Berkeley National Laboratory, University of California, Berkeley, CA.
1310
1311       It is currently being maintained by tcpdump.org.
1312
1313       The current version is available via HTTPS:
1314
1315              https://www.tcpdump.org/
1316
1317       The original distribution is available via anonymous ftp:
1318
1319              ftp://ftp.ee.lbl.gov/old/tcpdump.tar.Z
1320
1321       IPv6/IPsec  support  is  added by WIDE/KAME project.  This program uses
1322       OpenSSL/LibreSSL, under specific configurations.
1323

BUGS

1325       To   report   a   security   issue   please   send   an    e-mail    to
1326       security@tcpdump.org.
1327
1328       To  report  bugs and other problems, contribute patches, request a fea‐
1329       ture, provide generic feedback etc. please see the file CONTRIBUTING in
1330       the tcpdump source tree root.
1331
1332       NIT doesn't let you watch your own outbound traffic, BPF will.  We rec‐
1333       ommend that you use the latter.
1334
1335       On Linux systems with 2.0[.x] kernels:
1336
1337              packets on the loopback device will be seen twice;
1338
1339              packet filtering cannot be done in the kernel, so that all pack‐
1340              ets  must  be  copied from the kernel in order to be filtered in
1341              user mode;
1342
1343              all of a packet, not just the part that's  within  the  snapshot
1344              length,  will be copied from the kernel (the 2.0[.x] packet cap‐
1345              ture mechanism, if asked to  copy  only  part  of  a  packet  to
1346              userspace,  will  not report the true length of the packet; this
1347              would cause most IP packets to get an error from tcpdump);
1348
1349              capturing on some PPP devices won't work correctly.
1350
1351       We recommend that you upgrade to a 2.2 or later kernel.
1352
1353       Some attempt should be made to reassemble IP fragments or, at least  to
1354       compute the right length for the higher level protocol.
1355
1356       Name server inverse queries are not dumped correctly: the (empty) ques‐
1357       tion section is printed rather than real query in the  answer  section.
1358       Some  believe  that  inverse queries are themselves a bug and prefer to
1359       fix the program generating them rather than tcpdump.
1360
1361       A packet trace that crosses a daylight savings time  change  will  give
1362       skewed time stamps (the time change is ignored).
1363
1364       Filter  expressions  on  fields  other than those in Token Ring headers
1365       will not correctly handle source-routed Token Ring packets.
1366
1367       Filter expressions on fields other than those in  802.11  headers  will
1368       not  correctly  handle  802.11 data packets with both To DS and From DS
1369       set.
1370
1371       ip6 proto should chase header chain, but at this moment  it  does  not.
1372       ip6 protochain is supplied for this behavior.
1373
1374       Arithmetic  expression  against  transport  layer headers, like tcp[0],
1375       does not work against IPv6 packets.  It only looks at IPv4 packets.
1376
1377
1378
1379                               21 December 2020                     TCPDUMP(8)
Impressum