Basic Usage
| |
Common Options
| Option | Description |
|---|---|
| -i | Interface to capture from |
| -w | Write packets to file |
| -r | Read packets from file |
| -c | Capture |
| -f | Capture filter (BPF syntax) |
| -Y | Display filter (Wireshark syntax) |
| -T fields | Output specific fields |
| -e | Specify field to output (with -T fields) |
| -E | Output formatting (e.g., header=y, separator=,) |
| -V | Verbose output (packet details) |
| -l | Line-buffered output |
Examples
Capture on eth0 and display live:
1tshark -i eth0Capture 100 packets to a file:
1tshark -i eth0 -c 100 -w capture.pcapRead and filter packets from a file:
1tshark -r capture.pcap -Y "http"Show only source and destination IPs:
1tshark -i eth0 -T fields -e ip.src -e ip.dstUse a capture filter (only TCP traffic):
1tshark -i eth0 -f "tcp"Use a display filter (only HTTP requests):
1tshark -i eth0 -Y "http.request"
Useful Filters
- IP address:
ip.addr == 192.168.1.1 - TCP port:
tcp.port == 80 - HTTP requests:
http.request - DNS queries:
dns.qry.name == "example.com" - Show only TCP packets:
tcp
Output Formatting
CSV output:
1tshark -r file.pcap -T fields -e frame.number -e ip.src -e ip.dst -E header=y -E separator=,JSON output:
1tshark -r file.pcap -T json
More Help
List interfaces:
1tshark -DList all fields:
1tshark -G fieldsMan page:
1man tshark