Difference between revisions of "Wireshark"

From ArchWiki
Jump to navigation Jump to search
m (Installation: Clean up installation section.)
m (Capturing privileges: link specific section)
 
(23 intermediate revisions by 12 users not shown)
Line 3: Line 3:
 
[[fr:Wireshark]]
 
[[fr:Wireshark]]
 
[[ja:Wireshark]]
 
[[ja:Wireshark]]
 +
[[pt:Wireshark]]
 
[[ru:Wireshark]]
 
[[ru:Wireshark]]
[[zh-CN:Wireshark]]
+
[[zh-hans: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.
+
[https://www.wireshark.org/ Wireshark] is a free and open-source packet analyzer. It is used for network troubleshooting, analysis, software and communications protocol development, and education.
  
==Installation==
+
== Installation ==
  
The wireshark package has been split into the CLI version as well as GTK and Qt frontends, which depend on the CLI.
+
[[Install]] the {{pkg|wireshark-qt}} package for the Wireshark GUI or {{pkg|wireshark-cli}} for just the {{ic|tshark}} CLI.
  
* CLI version - [[pacman|Install]] package {{Pkg|wireshark-cli}}.
+
{{Note|The deprecated GTK+ interface has been removed in Wireshark 3.0.}}
* GTK frontend - [[pacman|Install]] package {{Pkg|wireshark-gtk}}.
 
* Qt frontend - [[pacman|Install]] package {{Pkg|wireshark-qt}}.
 
  
== Capturing as normal user ==
+
== Capturing privileges ==
  
Running Wireshark as root is insecure.
+
Do not run Wireshark as root, it is insecure. Wireshark has implemented privilege separation [https://wiki.wireshark.org/CaptureSetup/CapturePrivileges#Most_UNIXes].
  
Arch Linux uses
+
The {{Pkg|wireshark-cli}} [[PKGBUILD#install|install script]] sets packet capturing [[capabilities]] on the {{ic|/usr/bin/dumpcap}} executable.
[http://wiki.wireshark.org/CaptureSetup/CapturePrivileges#Other_Linux_based_systems_or_other_installation_methods method from Wireshark wiki]
 
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=
+
{{ic|/usr/bin/dumpcap}} can only be executed by root and members of the {{ic|wireshark}} group, therefore to use Wireshark as a normal user you have to add your user to the {{ic|wireshark}} [[user group]] (see [[Users and groups#Group management]]).
/usr/bin/dumpcap = cap_net_admin,cap_net_raw+eip
 
}}
 
  
{{ic|/usr/bin/dumpcap}} is the only process that has privileges to
+
== A few capturing techniques ==
capture packets. {{ic|/usr/bin/dumpcap}} can only be run by root and
 
members of the {{ic|wireshark}} group.
 
  
There are two methods to capture as a normal user :
+
There are a number of different ways to capture exactly what you are looking for in Wireshark, by applying [https://wiki.wireshark.org/CaptureFilters capture filters] or [https://wiki.wireshark.org/DisplayFilters display filters].
=== Add the user to the wireshark group===
 
To use wireshark as a normal user, add user to the {{ic|wireshark}} [[group]].
 
  
=== Use sudo ===
+
{{Note|To learn the capture filter syntax, see {{man|7|pcap-filter}}. For display filters, see {{man|4|wireshark-filter}}.}}
You can use [[sudo]] to temporarily change group to
 
{{ic|wireshark}}. The following line allows all users in the wheel
 
group to run programs with GID set to wireshark GID:
 
  
{{bc|1=%wheel ALL=(:wireshark) /usr/bin/wireshark, /usr/bin/tshark}}
+
=== Filtering TCP packets ===
  
Then run wireshark with
+
If you want to see all the current TCP packets, type {{ic|tcp}} into the "Filter" bar or in the CLI, enter:
{{bc|$ sudo -g wireshark wireshark}}
 
  
==A few capturing techniques==
+
$ tshark -f "tcp"
  
There are a number of different ways to capture exactly what you are looking for in Wireshark, by applying filters.
+
=== Filtering UDP packets ===
  
{{Note|To learn the filter syntax, see man pcap-filter(7).}}
+
If you want to see all the current UDP packets, type {{ic|udp}} into the "Filter" bar or in the CLI, enter:
  
===Filtering TCP packets===
+
$ tshark -f "udp"
If you want to see all the current TCP packets, type {{ic|tcp}} into the "Filter" bar.
 
  
===Filtering UDP packets===
+
=== Filter packets to a specific IP address ===
If you want to see all the current UDP packets, type {{ic|udp}} into the "Filter" bar.
 
  
===Filter packets to a specific IP Address===
+
* If you would like to see all the traffic going to a specific address, enter display filter {{ic|1=ip.dst == 1.2.3.4}}, replacing {{ic|1.2.3.4}} with the IP address the outgoing traffic is being sent to.
* If you would like to see all the traffic going to a specific address, enter {{ic|<nowiki>ip.dst == 1.2.3.4</nowiki>}}, replacing {{ic|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 display filter {{ic|1=ip.src == 1.2.3.4}}, 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 display filter {{ic|1=ip.addr == 1.2.3.4}}, replacing {{ic|1.2.3.4}} with the relevant IP address.
  
* 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.
+
=== Exclude packets from a specific IP address ===
  
* 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.
+
ip.addr != 1.2.3.4
 +
 
 +
=== Filter packets to LAN ===
 +
 
 +
{{Expansion|192.168.0.0/16 is not the only private address range.}}
 +
 
 +
To only see LAN traffic, no internet traffic run
 +
 
 +
ip.src==192.168.0.0/16 and ip.dst==192.168.0.0/16
 +
 
 +
=== Filter packets by port ===
 +
 
 +
See all traffic on 2 ports or more:
 +
 
 +
tcp.port==80||tcp.port==3306
 +
tcp.port==80||tcp.port==3306||tcp.port==443

Latest revision as of 18:09, 17 May 2019

Wireshark is a free and open-source packet analyzer. It is used for network troubleshooting, analysis, software and communications protocol development, and education.

Installation

Install the wireshark-qt package for the Wireshark GUI or wireshark-cli for just the tshark CLI.

Note: The deprecated GTK+ interface has been removed in Wireshark 3.0.

Capturing privileges

Do not run Wireshark as root, it is insecure. Wireshark has implemented privilege separation [1].

The wireshark-cli install script sets packet capturing capabilities on the /usr/bin/dumpcap executable.

/usr/bin/dumpcap can only be executed by root and members of the wireshark group, therefore to use Wireshark as a normal user you have to add your user to the wireshark user group (see Users and groups#Group management).

A few capturing techniques

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

Note: To learn the capture filter syntax, see pcap-filter(7). For display filters, see wireshark-filter(4).

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

Exclude packets from a specific IP address

ip.addr != 1.2.3.4

Filter packets to LAN

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: 192.168.0.0/16 is not the only private address range. (Discuss in Talk:Wireshark#)

To only see LAN traffic, no internet traffic run

ip.src==192.168.0.0/16 and ip.dst==192.168.0.0/16

Filter packets by port

See all traffic on 2 ports or more:

tcp.port==80||tcp.port==3306
tcp.port==80||tcp.port==3306||tcp.port==443