Overview
tcpdump is a command-line packet analyzer used to capture and inspect traffic on supported network interfaces. It is lightweight and useful on servers where a graphical analyzer is unavailable; capture files can later be reviewed in Wireshark.
Key features
Command-line capture; Berkeley Packet Filter expressions; pcap output; remote-server troubleshooting.
Install & first run
# Debian / Ubuntu / Kali
sudo apt install tcpdump
# macOS ships an old build; Homebrew has a current one
brew install tcpdump
# Capture 20 packets on one interface, no DNS or port-name lookups
sudo tcpdump -i eth0 -nn -c 20
# Filter by host and port, and write a pcap (-w writes files; there is no -o)
sudo tcpdump -i eth0 -nn -w lab.pcap 'host 192.168.1.10 and tcp port 443'
# Read the capture back
tcpdump -nn -r lab.pcap
Capture only traffic on networks you own or administer. Filter syntax is pcap-filter(7), the same grammar Wireshark uses. Docs: https://www.tcpdump.org/manpages/tcpdump/
Real-world example
Capture a short, approved lab trace filtered to a specific host or port, then analyze the pcap locally.
Common questions
Does tcpdump decrypt TLS traffic automatically?
No. It can capture encrypted traffic, but decryption requires appropriate keys and supported conditions.
How do I capture on a busy link without dropping packets?
Write straight to disk with -w and increase the buffer with -B; analysis happens later in Wireshark. Printing decoded packets is what drops frames.
Why are my packets truncated?
Default snaplen cuts at 262144 bytes only if you set -s 0; otherwise set -s 0 explicitly to capture full frames.
Can I capture without root?
Yes if the binary has file capabilities (CAP_NET_RAW) or you belong to a group granted them. Distributions often ship both options.
Related tools
Autopsy
Graphical digital-forensics platform for disk images: timeline, keyword search, artifact review and reporting. Free, on Windows, macOS and Linux.
Volatility 3
Memory forensics: extract processes, network connections and injected code from RAM captures. Free, open source, Python 3.
Wireshark
Deep packet analysis with the reference protocol dissector, plus tshark for scripted captures and filtering. Free, open source.
Related reading: Wireshark vs tcpdump: Packet Capture & Analysis Guide
Keep exploring: browse every assessment phase in the Pentest Hub.
Authorized testing only — only ever test systems you own or have explicit written permission to assess.
