在 Debian 上,dumpcap(Wireshark 抓包后端)默认需要 root 权限 才能访问网络接口。为了普通用户也能抓包,而不用 sudo,通常需要配置 capture 权限 / group。
以下是常见、推荐的做法:
wireshark 组(Debian 默认支持)sudo apt update
sudo apt install wireshark dumpcap
安装过程中会问:
Should non-superusers be able to capture packets? 选 Yes
这会自动:
wireshark 组dumpcap 的权限sudo usermod -aG wireshark $USER
newgrp wireshark
或 注销再登录
dumpcap -D
能列出网卡即成功。
如果安装时没选 “允许普通用户抓包”:
which dumpcap
通常是:
/usr/bin/dumpcap
sudo chgrp wireshark /usr/bin/dumpcap
sudo chmod 754 /usr/bin/dumpcap
sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap
sudo groupadd wireshark
sudo usermod -aG wireshark $USER
sudo dumpcap -i eth0
或
sudo wireshark
Couldn't run /usr/bin/dumpcap: Permission denied
解决:确认用户在 wireshark 组,且已重新登录。
dumpcap -D
为空 → 检查:
setcap 是否生效通常需要:
--privilegedCAP_NET_RAWsudo apt install wireshark
sudo usermod -aG wireshark $USER
# 注销重登录
如果你是在 服务器 / Docker / 无 GUI 环境,可以告诉我,我可以给你更具体的配置。