默认情况下,访问网络端口需要root权限,而wireshark的只是/usr/share/dumpcap的一个UI,/usr/share/dumpcap需要root权限,所以没法non-root用户无法读取网卡列表。
解决办法很简单,sudo wireshark
但是wireshark官方不推荐这么做:
Running as user "root" and group "root".
This could be dangerous.
If you‘re running Wireshark this way in order to perform live capture, you may want to be aware that there is a better way documented at
所以用另一种方法,改变/usr/share/dumpcap的group,添加一个group:wireshark,chgrp到wireshark组,再改成750权限,这样方便权限控制。
[plain] view plaincopy
- sudo -s
- groupadd wireshark
- usermod -a -G wireshark <You own username>
- chgrp wireshark /usr/bin/dumpcap
- chmod 4750 /usr/bin/dumpcap
又参考网上的解决方案,执行下面命令
[plain] view plaincopy
- setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap
用getcap /usr/bin/dumpcap,输出应当是/usr/bin/dumpcap = cap_net_admin,cap_net_raw+eip,说明生效
注意得注销一下才能生效
官方解决方案http://packetlife.net/blog/2010/mar/19/sniffing-wireshark-non-root-user/
wireshark添加用户执行
时间: 2024-10-27 01:09:33