在 Debian 上 dumpcap 报错的原因通常集中在权限、依赖、接口、配置这几类。下面按常见程度给你梳理。
报错类似:
could not open device eth0: Permission denied
或
The capture session could not be initiated on interface 'eth0'
dumpcap 需要访问 /dev/net/tun 或 raw socket,普通用户默认无权限。
sudo dpkg-reconfigure wireshark-common
选择 Yes,会把用户加入 wireshark 组:
sudo usermod -aG wireshark $USER
注销重新登录后生效。
或临时用 root:
sudo dumpcap -i eth0
Debian 上 dumpcap 依赖 cap_net_raw,cap_net_admin:
getcap /usr/bin/dumpcap
正常应看到:
/usr/bin/dumpcap = cap_net_raw,cap_net_admin+eip
如果没有:
sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap
报错:
That device is not up
或
No such device
检查:
ip link
例如 Debian 新版本可能是:
ens33eth0wlan0用法:
dumpcap -i ens33
which dumpcap
若没有:
sudo apt update
sudo apt install wireshark-common
容器或受限环境中常见:
Can't open netlink socket
解决:
--no-promiscuous-mode--capture-comment写文件时报错:
Unable to write to file
检查:
df -h
ls -ld /tmp
sudo dumpcap -i eth0 -w /tmp/test.pcap
或普通用户(已配置权限):
dumpcap -i eth0 -w ~/capture.pcap
把完整报错信息贴出来(最好带命令),我可以直接帮你定位是哪一类问题。