Section: (pj)
Updated: 2021-10-19
Index Return to Main Contents


/usr/sbin/tcpdump [options] [expression]  


So the man page has pretty much all you need, but here are the most useful options:

-i interface: Sets the interface to listen on, e.g. eth0 or wlan0. Defaults to eth0.
-s n: Sets the size of packets. If you say "-s 0," tcpdump will grab the entire packet.
-xX: Print the packet data in hex and ascii. (x = hex, X = ascii)
-w f: Write the packets to file f. You can say -w myfile -w - to get a "tee" effect.
-r f: Read the packets from file f.
-p Don't use promiscuous mode. This can simplify your rules to avoid noise and also may let you run this without root privileges (not sure about that though).

For an expression, your probably want something like this:


You can limit the noise to just one protocol like this:

host && port 80

You can limit direction like this:

dst host && port 80


host dst && port 80

You can combine expressions with not, and, or, and parentheses. You can pass the expression as several arguments or a single argument, so for complex expressions with parens you may want to just quote the whole thing.

Here's a full example:

tcpdump -s 0 -xX -w http -w - 'host hendrix && port 910'

A nice way to capture dns requests:

tcpdump -i enp10s0 -s 350 -C 100 -nn dst port 53



Paul A. Jungwirth.




This document was created by man2html, using the manual pages.
Time: 13:26:45 GMT, July 18, 2024