Wireshark is a free and open-source packet analyzer. It is used for network troubleshooting, analysis, software and communications protocol development, and education.
Install the package for the Wireshark GUI or for just the CLI.
is an alternative terminal UI.
Do not run Wireshark as root; it is insecure. Wireshark has implemented privilege separation, which means that the Wireshark GUI (or the tshark CLI) can run as a normal user while the dumpcap capture utility runs as root.
/usr/bin/dumpcap can only be executed by root and members of the
wireshark group, so to use Wireshark as a normal user, you have to add your user to the
wireshark user group.
A few capturing techniques
Filtering TCP packets
If you want to see all the current TCP packets, type
tcp into the Filter bar or in the CLI, enter:
$ tshark -f "tcp"
Filtering UDP packets
If you want to see all the current UDP packets, type
udp into the Filter bar or in the CLI, enter:
$ tshark -f "udp"
Filter packets to a specific IP address
- If you would like to see all the traffic going to a specific address, enter display filter
ip.dst == 188.8.131.52, replacing
184.108.40.206with the IP address the outgoing traffic is being sent to.
- If you would like to see all the incoming traffic for a specific address, enter display filter
ip.src == 220.127.116.11, replacing
18.104.22.168with the IP address the incoming traffic is being sent to.
- If you would like to see all the incoming and outgoing traffic for a specific address, enter display filter
ip.addr == 22.214.171.124, replacing
126.96.36.199with the relevant IP address.
Exclude packets from a specific IP address
ip.addr != 188.8.131.52
Filter packets to LAN
To only see LAN traffic and no internet traffic, run
(ip.src==10.0.0/8 AND ip.dst==10.0.0/8) OR (ip.src==172.16.0.0/12 AND ip.dst==172.16.0.0/12) OR (ip.src==192.168.0.0/16 and ip.dst==192.168.0.0/16)
This will filter traffic within any of the private network spaces.
Filter packets by port
See all traffic on two ports or more:
Headless capturing with dumpcap
dumpcap is part of Wireshark and can be used for capturing packets without the GUI. Used in combination with tmux will allow the capture of packets in a detached session.
To see all dumpcap options, use the
The following example will provide a ringbuffer capture. It captures twenty
.pcap files of 100MB each, replacing the oldest file with the twenty-first file and so on… This allows a continuous capture without exhausting disk space.
# dumpcap -i 1 -b filesize:100000 -b files:20 -w mycapture.pcapng
-i− interface number (listed from
-b filesize:− file size in kB before starting a new
-b files:− the number of files to capture before overwriting the oldest
-w− write the output to the file