非root用戶正常使用wireshark方法

今天在linux環境下運行wireshark抓包,安裝好wireshark後,開始抓包總是報錯,內容如下:

The capture session could not be initiated (failed to set hardware filter to promiscuous mode)

Please check to make sure you have sufficient permissions, and that you have


查詢解決方法,結果是將選項中的混雜模式關閉,關閉後仍然報錯,繼續查詢,突然想起來可能是用戶權限問題,然後用sudo wireshark打開wireshark就正常了,但是wireshark官方不推薦這麼做:

Running as user "root" and group "root".
This could be dangerous.

dumpcap需要root權限才能使用的,以普通用戶打開Wireshark,Wireshark當然沒有權限使用dumpcap進行截取封包。


所以用另一種方法,改變/usr/share/dumpcap的group,添加一個group:wireshark,chgrp到wireshark組,再改成4755權限,這樣方便權限控制,具體步驟如下:


1、添加用戶組,我以wireshark爲例
sudo groupadd wireshark

2、將dumpcap更改爲wireshark用戶組
sudo chgrp wireshark /usr/bin/dumpcap

3、讓wireshark用戶組有root權限使用dumpcap
sudo chmod 4755 /usr/bin/dumpcap

4、將自己加入wireshark用戶組,我的用戶是godben,你添加需要更改這個。
sudo gpasswd -a godben wireshark

這樣就完成,你可以使用自己的用戶打開Wireshark,並且有權限進行操作了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章