tcpdump
TLDR
Capture packets on default interface
SYNOPSIS
tcpdump [options] [filter expression]
DESCRIPTION
tcpdump is a packet analyzer that captures and displays network traffic. It uses libpcap to capture packets from network interfaces and can filter traffic using Berkeley Packet Filter (BPF) syntax.
The tool can capture packets in real-time, display their contents in various formats, and save them to files for later analysis. Output can show packet headers, full content, or hexadecimal dumps.
tcpdump is essential for network troubleshooting, security analysis, and protocol debugging. It's the command-line counterpart to graphical tools like Wireshark.
PARAMETERS
-i interface
Capture on specific interface.-w file
Write packets to file.-r file
Read packets from file.-c count
Capture only count packets.-n
Don't resolve hostnames.-nn
Don't resolve hostnames or ports.-v, -vv, -vvv
Verbose output levels.-A
Print packets in ASCII.-X
Print packets in hex and ASCII.-s snaplen
Capture snaplen bytes per packet (0=full).-e
Print link-layer header.-q
Quick output (less protocol info).-D
List available interfaces.
FILTER EXPRESSIONS
host ip: Filter by host
port num: Filter by port
src/dst: Source or destination
tcp/udp/icmp: Protocol types
and/or/not: Boolean operators
Example: `tcpdump 'tcp port 80 and host 192.168.1.1'`
CAVEATS
Requires root privileges. Packet capture can impact performance on high-traffic networks. Full packet capture uses significant disk space. Some protocols are encrypted and contents cannot be viewed.
HISTORY
tcpdump was originally written by Van Jacobson, Craig Leres, and Steven McCanne at the Lawrence Berkeley National Laboratory in 1988. It became the foundation for network packet analysis on Unix systems. The libpcap library was extracted from tcpdump and is now used by many network analysis tools including Wireshark.


