Tcpdump prints out the headers of packets on a network interface
that match the boolean expression. It can also be run with the
-w
flag, which causes it to save the packet data to a file for later
analysis, and/or with the
-b
flag, which causes it to read from a saved packet file rather than to
read packets from a network interface. In all cases, only packets that
match
expression
will be processed by
tcpdump.
Tcpdump
will, if not run with the
-c
flag, continue capturing packets until it is interrupted by a SIGINT
signal (generated, for example, by typing your interrupt character,
typically control-C) or a SIGTERM signal (typically generated with the
kill(1)
command); if run with the
-c
flag, it will capture packets until it is interrupted by a SIGINT or
SIGTERM signal or the specified number of packets have been processed.
When
tcpdump
finishes capturing packets, it will report counts of:
-
packets ``received by filter'' (the meaning of this depends on the OS on
which you're running
tcpdump,
and possibly on the way the OS was configured - if a filter was
specified on the command line, on some OSes it counts packets regardless
of whether they were matched by the filter expression, and on other OSes
it counts only packets that were matched by the filter expression and
were processed by
tcpdump);
-
packets ``dropped by kernel'' (this is the number of packets that were
dropped, due to a lack of buffer space, by the packet capture mechanism
in the OS on which
tcpdump
is running, if the OS reports that information to applications; if not,
it will be reported as 0).
On platforms that support the SIGINFO signal, such as most BSDs, it will
report those counts when it receives a SIGINFO signal (generated, for
example, by typing your ``status'' character, typically control-T) and
will continue capturing packets.
Reading packets from a network interface may require that you have
special privileges:
- Under SunOS 3.x or 4.x with NIT or BPF:
-
You must have read access to
/dev/nit
or
/dev/bpf*.
- Under Solaris with DLPI:
-
You must have read/write access to the network pseudo device, e.g.
/dev/le.
On at least some versions of Solaris, however, this is not sufficient to
allow
tcpdump
to capture in promiscuous mode; on those versions of Solaris, you must
be root, or
tcpdump
must be installed setuid to root, in order to capture in promiscuous
mode.
- Under HP-UX with DLPI:
-
You must be root or
tcpdump
must be installed setuid to root.
- Under IRIX with snoop:
-
You must be root or
tcpdump
must be installed setuid to root.
- Under Linux:
-
You must be root or
tcpdump
must be installed setuid to root.
- Under Ultrix and Digital UNIX:
-
Once the super-user has enabled promiscuous-mode operation using
pfconfig(8),
any user may capture network traffic with
tcpdump.
- Under BSD:
-
You must have read access to
/dev/bpf*.
Reading a saved packet file doesn't require special privileges.