Difference between revisions of "Wireshark"

From ArchWiki
Jump to: navigation, search
m (hc instead of bc)
(Add caveat on Qt vs GTK to help troubleshooting)
 
(24 intermediate revisions by 18 users not shown)
Line 1: Line 1:
[[Category:Security]][[Category:Networking]]
+
[[Category:Security]]
 +
[[Category:Networking]]
 
[[fr:Wireshark]]
 
[[fr:Wireshark]]
 +
[[ja:Wireshark]]
 +
[[ru:Wireshark]]
 +
[[zh-CN:Wireshark]]
 
Wireshark is a free and open-source packet analyzer. It is used for network troubleshooting, analysis, software and communications protocol development, and education. Originally named Ethereal, in May 2006 the project was renamed Wireshark due to trademark issues.
 
Wireshark is a free and open-source packet analyzer. It is used for network troubleshooting, analysis, software and communications protocol development, and education. Originally named Ethereal, in May 2006 the project was renamed Wireshark due to trademark issues.
  
 
==Installation==
 
==Installation==
  
The {{Pkg|wireshark}} package has been split into the CLI version and GTK frontend, which depends on the CLI.
+
The wireshark package has been split into the CLI version as well as GTK and Qt frontends, which depend on the CLI.
  
CLI version can be [[pacman|installed]] with the package {{Pkg|wireshark-cli}}, available in the [[official repositories]].
+
{{Warning | The Qt frontend, along with missing some features, is also not as stable as the GTK frontend. If you have issues with listing network interfaces, enabling monitor mode, and/or permissions, even after setting everything up correctly, try using the GTK version and see if your issues persist.}}
  
GTK frontend can be [[pacman|installed]] with the package {{Pkg|wireshark-gtk}}, available in the [[official repositories]].
+
* CLI version - [[pacman|Install]] package {{Pkg|wireshark-cli}}.
 +
* GTK frontend - [[pacman|Install]] package {{Pkg|wireshark-gtk}}.
 +
* Qt frontend - [[pacman|Install]] package {{Pkg|wireshark-qt}}.
  
 
== Capturing as normal user ==
 
== Capturing as normal user ==
Line 17: Line 23:
 
Arch Linux uses
 
Arch Linux uses
 
[http://wiki.wireshark.org/CaptureSetup/CapturePrivileges#Other_Linux_based_systems_or_other_installation_methods method from Wireshark wiki]
 
[http://wiki.wireshark.org/CaptureSetup/CapturePrivileges#Other_Linux_based_systems_or_other_installation_methods method from Wireshark wiki]
to separate privileges.  When {{Pkg|wireshark-gtk}} is installed, [[PKGBUILD#install|install script]] sets {{ic|/usr/bin/dumpcap}} capabilities.
+
to separate privileges.  When {{Pkg|wireshark-cli}} is installed, [[PKGBUILD#install|install script]] sets {{ic|/usr/bin/dumpcap}} capabilities.
  
 
{{hc|$ getcap /usr/bin/dumpcap|2=
 
{{hc|$ getcap /usr/bin/dumpcap|2=
Line 27: Line 33:
 
members of the {{ic|wireshark}} group.
 
members of the {{ic|wireshark}} group.
  
To use wireshark as a normal user, add user to the wireshark group:
+
There are two methods to capture as a normal user :
 +
=== Add the user to the wireshark group===
 +
To use wireshark as a normal user, add user to the {{ic|wireshark}} [[group]].
  
{{bc|# gpasswd -a "username" wireshark}}
+
=== Use sudo ===
 
+
You can use [[sudo]] to temporarily change group to  
Another way is to use [[sudo]] to temporarily change group to  
+
 
{{ic|wireshark}}. The following line allows all users in the wheel
 
{{ic|wireshark}}. The following line allows all users in the wheel
 
group to run programs with GID set to wireshark GID:
 
group to run programs with GID set to wireshark GID:
Line 47: Line 54:
  
 
===Filtering TCP packets===
 
===Filtering TCP packets===
If you want to see all the current TCP packets, type {{ic|tcp}} into the "Filter" bar.
+
If you want to see all the current TCP packets, type {{ic|tcp}} into the "Filter" bar or in the CLI, enter:
 +
 
 +
$ tshark -f "tcp"
  
 
===Filtering UDP packets===
 
===Filtering UDP packets===
If you want to see all the current UDP packets, type {{ic|udp}} into the "Filter" bar.
+
If you want to see all the current UDP packets, type {{ic|udp}} into the "Filter" bar or in the CLI, enter:
 +
 
 +
$ tshark -f "udp"
  
 
===Filter packets to a specific IP Address===
 
===Filter packets to a specific IP Address===
Line 56: Line 67:
  
 
* If you would like to see all the incoming traffic for a specific address, enter {{ic|<nowiki>ip.src == 1.2.3.4</nowiki>}}, replacing {{ic|1.2.3.4}} with the IP address the incoming traffic is being sent to.
 
* If you would like to see all the incoming traffic for a specific address, enter {{ic|<nowiki>ip.src == 1.2.3.4</nowiki>}}, replacing {{ic|1.2.3.4}} with 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 {{ic|<nowiki>ip.addr == 1.2.3.4</nowiki>}}, replacing {{ic|1.2.3.4}} with the relevant IP address.

Latest revision as of 23:23, 29 August 2016

Wireshark is a free and open-source packet analyzer. It is used for network troubleshooting, analysis, software and communications protocol development, and education. Originally named Ethereal, in May 2006 the project was renamed Wireshark due to trademark issues.

Installation

The wireshark package has been split into the CLI version as well as GTK and Qt frontends, which depend on the CLI.

Warning: The Qt frontend, along with missing some features, is also not as stable as the GTK frontend. If you have issues with listing network interfaces, enabling monitor mode, and/or permissions, even after setting everything up correctly, try using the GTK version and see if your issues persist.

Capturing as normal user

Running Wireshark as root is insecure.

Arch Linux uses method from Wireshark wiki to separate privileges. When wireshark-cli is installed, install script sets /usr/bin/dumpcap capabilities.

$ getcap /usr/bin/dumpcap
/usr/bin/dumpcap = cap_net_admin,cap_net_raw+eip

/usr/bin/dumpcap is the only process that has privileges to capture packets. /usr/bin/dumpcap can only be run by root and members of the wireshark group.

There are two methods to capture as a normal user :

Add the user to the wireshark group

To use wireshark as a normal user, add user to the wireshark group.

Use sudo

You can use sudo to temporarily change group to wireshark. The following line allows all users in the wheel group to run programs with GID set to wireshark GID:

%wheel ALL=(:wireshark) /usr/bin/wireshark, /usr/bin/tshark

Then run wireshark with

$ sudo -g wireshark wireshark

A few capturing techniques

There are a number of different ways to capture exactly what you are looking for in Wireshark, by applying filters.

Note: To learn the filter syntax, see man pcap-filter(7).

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 ip.dst == 1.2.3.4, replacing 1.2.3.4 with 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 ip.src == 1.2.3.4, replacing 1.2.3.4 with 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 ip.addr == 1.2.3.4, replacing 1.2.3.4 with the relevant IP address.