tcpdump Cheatsheet

Output Options

Use this tcpdump reference while you build software engineering projects, review code, or refresh the syntax you reach for most.

The flag table

Every flag people actually reach for, in one place.

FlagEffect
-i ifaceCapture on this interface
-nNo name resolution for addresses
-nnNo name resolution for addresses or ports and protocols
-NStrip the domain from host names (nic, not nic.example.com)
-vMore protocol detail, plus IP TTL, ID, total length, options
-vvEven more, full NFS and SMB decode, TCP option detail
-vvvMaximum verbosity
-qQuick, short one-line output, less protocol info
-ePrint the link-level header (MAC addresses, VLAN tags)
-APrint payload as ASCII, minus the link-level header
-xPayload as hex
-xxPayload as hex, including the link-level header
-XPayload as hex and ASCII side by side
-XXSame as -X plus the link-level header
-s lenSnapshot length, bytes captured per packet
-c nExit after n packets
-w fileWrite raw packets to a pcap file instead of printing
-r fileRead from a pcap file instead of an interface
-Q dirDirection: in, out, or inout
-lLine-buffer stdout, so pipes work live
-UPacket-buffer stdout, flush per packet with -w -
-tNo timestamp
-ttTimestamp as an unsigned Unix epoch seconds value
-tttDelta since the previous line
-ttttHuman-readable date and time
-tttttDelta since the first line
-#Print a packet number on each line
-B kibKernel capture buffer size in KiB
-Z userDrop privileges to user after opening the socket
-dDump the compiled BPF program and exit, do not capture

Reading a default output line

14:22:07.109233 IP 10.0.0.5.54321 > 93.184.216.34.443:
  Flags [S], seq 2847193, win 65535, options [mss 1460,sackOK,
  TS val 12345 ecr 0,nop,wscale 7], length 0
PieceMeaning
14:22:07.109233Capture timestamp, local time, microseconds
10.0.0.5.54321Source. The last dotted field is the port
>Direction of this packet
Flags [S]TCP flags, see the table below
seq / ackSequence and acknowledgement numbers
win 65535Advertised receive window
length 0Payload bytes, not frame size

Flag letters in Flags [...]:

LetterFlag
SSYN
.ACK, on its own means a bare ack
PPSH
FFIN
RRST
UURG
WCWR
EECE
noneNo flags set at all

So [S] is a connection open, [S.] is the SYN-ACK, [P.] is data with an ack riding along, and [R.] is a reset.

Verbosity levels compared

sudo tcpdump -i eth0 -nn -q port 443       # shortest useful line
sudo tcpdump -i eth0 -nn port 443          # default
sudo tcpdump -i eth0 -nn -v port 443       # adds TTL, IP id, length
sudo tcpdump -i eth0 -nn -vv port 443      # adds full option decode

-v is where the IP TTL shows up, which is what you want when you are guessing hop counts or spotting a spoofed source.

Seeing the payload

# Hex and ASCII together, the usual choice
sudo tcpdump -i eth0 -nn -X port 80

# ASCII only, readable for text protocols
sudo tcpdump -i eth0 -nn -A -s 0 'tcp port 80'

# Include the Ethernet header so you can read MACs and VLAN tags
sudo tcpdump -i eth0 -nn -e -XX port 80

-s 0 means the default full snaplen (262144 bytes in tcpdump 4.99), not "zero bytes". Older tcpdump defaulted to 68 or 96 bytes, which is why so many old recipes carry -s 0. On any modern build it is a no-op.

Timestamps you can correlate

Default relative-looking times are actually wall clock local time. Two formats matter when you cross-reference logs:

# Absolute date and time, for matching against application logs
sudo tcpdump -i eth0 -nn -tttt port 443

# Epoch seconds, for feeding into a script
sudo tcpdump -i eth0 -nn -tt port 443

# Delta between consecutive packets, for spotting stalls
sudo tcpdump -nn -ttt -r capture.pcap 'tcp port 443'

-ttt is the fastest way to see a one-second retransmission gap or a 30-second idle timeout without doing arithmetic in your head.

Direction and quiet capture

# Only inbound packets, useful when your own replies are noise
sudo tcpdump -i eth0 -nn -Q in port 8080

# Only what this host sends
sudo tcpdump -i eth0 -nn -Q out port 8080

-Q is not supported on every platform and silently matters: if the OS does not implement it, tcpdump tells you rather than filtering wrongly. The portable fallback is an address-based filter, src host <me>.

Piping to another tool? tcpdump -l -nn ... | grep --line-buffered RST. Without -l on the tcpdump side and --line-buffered on grep, you get nothing for minutes and assume the filter is broken.