Ultimate Tcpdump Cheat Sheet
Ultimate Tcpdump Cheat Sheet
The standard command-line packet analyzer for packet capturing and filtering.
1. Basic Capture
Start listening on an interface immediately. Requires Root/Sudo.
List Interfaces
Listen on Interface
Capture packets on eth0.
Listen on All Interfaces
Limit Count (-c)
Stop after capturing 10 packets (otherwise it runs forever).
2. File Operations (PCAP)
Always save your captures to a .pcap file so you can analyze them in Wireshark later.
Write to File (-w)
Read from File (-r)
Analyze a saved file instead of live traffic.
Snapshot Length (-s)
By default, tcpdump might truncate large packets. Use -s 0 to capture the full packet size.
3. Display Options
Control how the packets look in your terminal.
| Flag | Description |
|---|---|
-n | No DNS Resolution. Shows IPs (1.2.3.4) instead of names (google.com). Faster. |
-nn | No Port Resolution. Shows port numbers (80) instead of names (http). |
-v, -vv, -vvv | Verbosity. Increases the amount of detail shown per packet. |
-A | ASCII. Print packet payload in ASCII (Great for reading Web traffic). |
-X | HEX & ASCII. Print payload in both Hex and ASCII. |
-t | No Timestamp. Removes the timestamp for cleaner output. |
Example: Readable Web Traffic
4. Core Filters (BPF)
Tcpdump uses "Berkeley Packet Filters". These are the most important part of the tool.
Host Filtering
Network Filtering
Port Filtering
Protocol Filtering
Simply type the protocol name.
5. Logic & Direction
Combine multiple filters using and, or, and not.
Source or Destination
Combining (AND)
Traffic coming from IP 1.2.3.4 AND going to port 80.
Excluding (NOT)
Capture everything EXCEPT SSH traffic.
Complex Logic
Note: When using parenthesis `()`, wrap the filter in quotes to avoid shell errors.
6. Advanced One-Liners
Ready-to-use commands for specific scenarios.
HTTP User Agents
Extract User-Agents from HTTP traffic.
Capture Cleartext Passwords
Look for "pass", "user", or "login" in the payload.
Detect Syn Scan
Look for packets with only the SYN flag set.

Post a Comment