/* ---[ Wireshark on Linux ]--- */
When you install the wireshark APT package on an Ubuntu system (in my case Xubuntu 11.10) and start it (as you), it will start up fine, but you can't immediately start sniffing packets because you'll have nothing showing in the Capture > Interface list to click on. For this to work on linux, wireshark's packet capture tool, dumpcap, has to have additional privileges (or capabilities) to run.
Naturally, you then think "I'll run it as root" and do sudo wireshark
. Yes! Now I can see eth0 and lo and any other network interfaces on my system. But wait, there's this pop-up dialog telling me that running wireshark as root is dangerous and it refers me to /usr/share/doc/wireshark-common/README.Debian, which mostly reads as mystical uber-geek mutterings. Then you see this link at the bottom https://blog.wireshark.org/2010/02/running-wireshark-as-you, which looks more promising.
It is a great article that shows you how to either give the setuid attribute to /usr/bin/dumpcap
or, preferably, use Linux capabilties to grant just the specific capabilities that dumpcap needs, without needing to run it as root.
Unfortunately, the instructions given for the second option on that page are wrong. There are three errors:
Error 0: The groupadd command has a spurious -g
Error 1: It forgets to set wireshark as the group for /usr/bin/dumpcap
Error 2: It gets the setcap instruction wrong.
/* ---[ Make it so ]--- */
Here is the new improved instruction set that I just got to work on my Xubuntu system:
$ sudo su - root
# sudo apt-get install libcap2-bin
# groupadd wireshark
# usermod -a -G wireshark <your-user-name>
# chmod 750 /usr/bin/dumpcap
# chgrp wireshark /usr/bin/dumpcap
# setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/dumpcap
(Note: on modern Ubuntu's you probably won't need to install libcap2-bin. I already had it.)
I believe you will also need to logout and log back in. You might be able to avoid this by invoking newgrp wireshark
, but I'm not sure your group setting is the only reason you would have to log out.
To be fair, the wireshark wiki does get it right on this page, but you have to look in the "Other Linux based methods" section, not the "Debian, Ubuntu and other Debian derivatives" section.