Skip to content

Wireshark CLI tools

100 commands

The utilities that ship with Wireshark — editcap, mergecap, capinfos, dumpcap and text2pcap — for working with capture files.

  • pcap
  • capture files
  • Wireshark

Install Wireshark CLI tools

sudo apt install wireshark-common

Setup and Info3

tshark -v

Displays the version information and compiled-in options for Tshark.

dumpcap -v

Displays the version information for the raw capture tool Dumpcap.

capinfos -v

Displays the version information for the capture file metadata tool Capinfos.

Interface Listing2

dumpcap -D

Lists all available network interfaces that can be used for capturing packets.

tshark -D

Lists available interfaces using Tshark which may differ slightly from Dumpcap regarding pipes.

File Metadata5

capinfos capture.pcap

Prints general metadata statistics about a capture file including duration and packet counts.

Link
capinfos -c capture.pcap

Displays only the total count of packets contained in the capture file.

Link
capinfos -u capture.pcap

Displays the start and end timestamps of the capture duration.

Link
capinfos -s capture.pcap

Displays the size of the capture file in bytes.

Link
capinfos -d capture.pcap

Displays the total data size of all packets excluding file overhead.

Link

Basic Capture2

dumpcap -i eth0 -w output.pcap

Captures packets from a specific interface and writes them directly to a file.

Link
dumpcap -i any -w output.pcap

Captures traffic from all available interfaces simultaneously on Linux systems.

Link

Capture Limits3

dumpcap -i eth0 -c 100 -w output.pcap

Stops the packet capture automatically after capturing exactly 100 packets.

Link
dumpcap -i eth0 -a duration:60 -w output.pcap

Stops the packet capture automatically after 60 seconds.

Link
dumpcap -i eth0 -a filesize:10000 -w output.pcap

Stops the capture when the output file size reaches 10,000 kilobytes.

Link

Ring Buffer2

dumpcap -i eth0 -b files:5 -b filesize:50000 -w buffer.pcap

Uses a ring buffer to keep the last 5 files of 50MB each, overwriting old ones.

Link
dumpcap -i eth0 -b duration:3600 -w hourly.pcap

Creates a new capture file every hour continuously.

Link

Capture Filters3

dumpcap -i eth0 -f "tcp port 80" -w web.pcap

Captures only TCP traffic destined for or originating from port 80.

Link
dumpcap -i eth0 -f "host 192.168.1.5" -w host.pcap

Captures only traffic involving the specific IP address 192.168.1.5.

Link
dumpcap -i eth0 -f "not port 22" -w no_ssh.pcap

Captures all traffic except SSH traffic on port 22.

Link

Promiscuous Mode1

dumpcap -i eth0 -p -w output.pcap

Captures in non-promiscuous mode, seeing only traffic addressed to the interface.

Link

Basic Analysis2

tshark -r capture.pcap

Reads and displays a summary of packets from an existing capture file.

Link
tshark -i eth0

Captures packets from an interface and prints decoded one-line summaries to the terminal.

Link

Time Formatting3

tshark -r capture.pcap -t ad

Displays packet timestamps as absolute dates with time.

Link
tshark -r capture.pcap -t ud

Displays packet timestamps using UTC absolute date and time.

Link
tshark -r capture.pcap -t d

Displays timestamps as the time delta from the previous displayed packet.

Link

Display Filters4

tshark -r capture.pcap -Y "http"

Displays only packets that are identified as HTTP protocol.

Link
tshark -r capture.pcap -Y "ip.addr == 192.168.1.1"

Displays only packets where the source or destination IP matches the address.

Link
tshark -r capture.pcap -Y "tcp.flags.reset == 1"

Displays only TCP packets where the RST (reset) flag is set.

Link
tshark -r capture.pcap -Y "frame.len > 1000"

Displays only packets with a frame length greater than 1000 bytes.

Link

Two-Pass Analysis1

tshark -r capture.pcap -2 -R "tcp.analysis.retransmission"

Performs a two-pass analysis to accurately detect and filter TCP retransmissions.

Link

Field Extraction3

tshark -r capture.pcap -T fields -e ip.src -e ip.dst

Extracts and prints only the source and destination IP addresses.

Link
tshark -r capture.pcap -T fields -e http.host -e http.request.uri

Extracts the HTTP host and requested URI from HTTP traffic.

Link
tshark -r capture.pcap -T fields -e dns.qry.name

Extracts only the DNS query names being requested in the traffic.

Link

CSV Output2

tshark -r capture.pcap -T fields -e frame.number -e ip.src -E separator=,

Outputs the extracted fields in CSV format separated by commas.

Link
tshark -r capture.pcap -T fields -e ip.src -E header=y

Includes a header row describing the fields in the text output.

Link

JSON Output3

tshark -r capture.pcap -T json

Exports the full dissection of packets into a detailed JSON format.

Link
tshark -r capture.pcap -T jsonraw

Exports the packet dissection to JSON including the raw hex data for fields.

Link
tshark -r capture.pcap -T ek

Exports packets in Newline Delimited JSON format suitable for Elasticsearch.

Link

Verbose Output2

tshark -r capture.pcap -V

Displays the full, verbose packet tree details for every packet in the file.

Link
tshark -r capture.pcap -O http

Displays full verbose details only for the HTTP protocol layer.

Link

Hex Output1

tshark -r capture.pcap -x

Prints the packet data in both hex and ASCII format alongside the summary.

Link

Statistics5

tshark -r capture.pcap -q -z io,phs

Displays the Protocol Hierarchy Statistics showing traffic distribution by protocol.

Link
tshark -r capture.pcap -q -z conv,ip

Displays a table of IPv4 conversations including packet counts and bytes.

Link
tshark -r capture.pcap -q -z conv,tcp

Displays a table of TCP conversations identifying active connections.

Link
tshark -r capture.pcap -q -z endpoints,ip

Lists all IPv4 endpoints found in the capture file with traffic stats.

Link
tshark -r capture.pcap -q -z expert

Displays expert info warnings, errors, and notes detected in the trace.

Link

Advanced Statistics5

tshark -r capture.pcap -q -z http,tree

Calculates and displays a statistical tree of HTTP packet distribution.

Link
tshark -r capture.pcap -q -z http,stat

Displays HTTP status code statistics and request distribution.

Link
tshark -r capture.pcap -q -z dns,tree

Displays a statistical tree summarizing DNS query types and response codes.

Link
tshark -r capture.pcap -q -z io,stat,1

Calculates traffic statistics in 1-second intervals.

Link
tshark -r capture.pcap -q -z io,stat,1,"COUNT(tcp.analysis.retransmission) tcp.analysis.retransmission"

Counts TCP retransmissions per second to identify network congestion.

Link

Decryption2

tshark -r capture.pcap -o "ssl.keys_list:0.0.0.0,443,http,server.pem"

Decrypts SSL/TLS traffic using the provided server private key file.

Link
tshark -r capture.pcap -o "tls.keylog_file:secrets.log"

Decrypts TLS traffic using a browser-generated session key log file.

Link

Protocol Preferences2

tshark -r capture.pcap -o "tcp.desegment_tcp_streams:TRUE"

Forces reassembly of TCP segments to analyze complete application layer payloads.

Link
tshark -r capture.pcap -d tcp.port==8080,http

Decodes traffic on TCP port 8080 as HTTP regardless of standard port assignments.

Link

Stream Analysis2

tshark -r capture.pcap -z follow,tcp,ascii,0

Follows TCP stream index 0 and displays the content in ASCII format.

Link
tshark -r capture.pcap -z follow,udp,hex,0

Follows UDP stream index 0 and displays the content in Hex format.

Link

Object Extraction2

tshark -r capture.pcap --export-objects http,./output_dir

Extracts all files (images, binaries) transferred via HTTP to the specified directory.

Link
tshark -r capture.pcap --export-objects smb,./output_dir

Extracts files transferred over SMB/CIFS shares to the specified directory.

Link

GeoIP1

tshark -r capture.pcap -T fields -e ip.src -e ip.geoip.country

Displays source IP addresses alongside their resolved GeoIP country.

Link

Name Resolution2

tshark -r capture.pcap -n

Disables network name resolution (DNS) to speed up processing.

Link
tshark -r capture.pcap -N n

Enables network name resolution to resolve IP addresses to hostnames.

Link

Filtering and Saving1

tshark -r full.pcap -Y "tcp.port == 80" -w http_only.pcap

Reads a capture file, applies a display filter, and saves the matches to a new file.

Link

Anonymization1

editcap -I 128 input.pcap output.pcap

Injects packet length errors or trims packets to remove sensitive payload data (requires editcap).

Link

Slicing1

tshark -r capture.pcap -s 64 -w header_only.pcap

Reads a file and saves only the first 64 bytes of each packet, discarding payloads.

Link

IPv6 Analysis2

tshark -r capture.pcap -Y "ipv6"

Filters and displays only IPv6 traffic.

Link
tshark -r capture.pcap -q -z conv,ipv6

Displays statistics for IPv6 conversations.

Link

Tunneling2

tshark -r capture.pcap -Y "gtp"

Filters traffic to show GPRS Tunneling Protocol packets used in mobile networks.

Link
tshark -r capture.pcap -Y "vxlan"

Filters traffic to show VXLAN encapsulated packets common in data centers.

Link

VLAN Analysis1

tshark -r capture.pcap -Y "vlan.id == 10"

Filters traffic belonging specifically to VLAN ID 10.

Link

WLAN Analysis1

tshark -r wifi.pcap -Y "wlan.fc.type_subtype == 0x08"

Filters specific 802.11 frame types, such as Beacon frames (subtype 0x08).

Link

USB Analysis1

tshark -i usbmon0

Captures USB traffic on Linux systems using the usbmon interface.

Link

Bluetooth Analysis1

tshark -i bluetooth0

Captures Bluetooth traffic if the hardware and drivers support monitor mode.

Link

VoIP Analysis2

tshark -r capture.pcap -Y "sip || rtp"

Filters traffic to show only SIP signaling and RTP media streams.

Link
tshark -r capture.pcap -q -z sip,stat

Displays statistics for SIP methods and response codes.

Link

Error Analysis2

tshark -r capture.pcap -Y "tcp.analysis.lost_segment"

Identifies packets that indicate a previous TCP segment was lost in transit.

Link
tshark -r capture.pcap -Y "tcp.analysis.window_full"

Identifies when the TCP receive window is full, indicating a potential bottleneck.

Link

Security Monitoring4

tshark -r capture.pcap -Y "http.request.method == POST"

Filters for HTTP POST requests which often contain form submissions or uploads.

Link
tshark -r capture.pcap -Y "tcp.port == 4444"

Filters for traffic on port 4444, a common default port for Metasploit payloads.

Link
tshark -r capture.pcap -Y "dns.qry.name contains \"base64\""

Searches for DNS queries containing suspicious strings like 'base64' indicating tunneling.

Link
tshark -r capture.pcap -Y "tls.handshake.extensions_server_name"

Inspects the SNI (Server Name Indication) in TLS handshakes to see target domains.

Link

Formatting2

tshark -r capture.pcap -T text -e frame.number

Forces standard text output even if configured otherwise in preferences.

Link
tshark -r capture.pcap -T tabs

Displays packet summaries with tab-separated columns for easier parsing.

Link

Live Display1

tshark -i eth0 -l

Flushes the standard output after every packet, useful when piping to other tools.

Link

Live Limits1

tshark -i eth0 -a duration:10

Captures and displays packets for 10 seconds before terminating.

Link

Read Filter1

tshark -r capture.pcap -R "ip.addr==1.2.3.4" -2

Uses a read filter with two-pass analysis, necessary for some complex filters.

Link

Merge1

mergecap -w merged.pcap file1.pcap file2.pcap

Combines multiple capture files into a single file based on packet timestamps.

Link

Compare1

diff <(tshark -r f1.pcap) <(tshark -r f2.pcap)

Uses bash process substitution and tshark to textually compare two capture files.

Link

Deduplication1

editcap -d input.pcap output.pcap

Removes duplicate packets from a capture file based on a moving time window.

Link

Time Adjustment1

editcap -t 3600 input.pcap output.pcap

Adjusts the timestamp of every packet in the file forward by 3600 seconds.

Link

Format Conversion1

editcap -F pcapng input.pcap output.pcapng

Converts an old PCAP file format to the newer, more versatile PCAPNG format.

Link

Protocol Hierarchy1

tshark -r capture.pcap -z io,phs,udp

Displays protocol hierarchy statistics specifically filtering for the UDP branch.

Link

Latency Analysis1

tshark -r capture.pcap -T fields -e frame.number -e tcp.analysis.ack_rtt

Extracts the Round Trip Time (RTT) for TCP acknowledgments to analyze latency.

Link

Large File Analysis1

tshark -r large.pcap -c 1000

Reads only the first 1000 packets of a large file to avoid loading everything.

Link

Credential Hunting2

tshark -r capture.pcap -Y "http.authbasic"

Filters for HTTP Basic Authentication headers which contain base64 credentials.

Link
tshark -r capture.pcap -Y "ftp.request.command == USER || ftp.request.command == PASS"

Filters for FTP login commands to capture cleartext usernames and passwords.

Link

Elasticsearch1

tshark -r capture.pcap -T ek -J "http tcp ip"

Generates Elasticsearch-compatible JSON only for the HTTP, TCP, and IP layers.

Link

Custom Columns1

tshark -r capture.pcap -o "gui.column.format:\"Source\",\"%s\",\"Dest\",\"%d\""

Overrides the default summary columns with custom columns defined in the command.

Link

Advanced Capture1

dumpcap -i eth0 -w output.pcap -f "tcp[13] & 8 != 0"

Uses a raw BPF bitmask filter to capture only TCP packets with the PSH flag set.

Link