I want to capture UDP packages sent by an FPGA with ~10 Gbit/s bandwidth. I found that tcpdump
combined with a fast SSD is perfectly capable of receiving a continuous 10 Gbit/s stream and storing it on disk without loss.
When I run sudo tcpdump
, everything works as expected.
However, I need to be able to run tcpdump
without sudo
. Without sudo
I get this error:
tcpdump: enp4s0f0: You don't have permission to capture on that device
(socket: Operation not permitted)
Here is what I found and tried so far to enable tcpdump
without sudo
:
sudo su
groupadd pcap
usermod -a -G pcap $USER
chgrp pcap /usr/sbin/tcpdump
chmod 750 /usr/sbin/tcpdump
setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump
Proposed solution from here
According to the various pages that list this solution, this should give my regular user account the possibility to run tcpdump
, right?
However, when I switch to my regular user account and run tcpdump
, I get this:
bash: /sbin/tcpdump: Permission denied
(note that this error message is different compared to the initial error message)
I've verified via getent group pcap
that my account is part of the pcap
group. I've also verified that /sbin/tcpdump
is owned by the group pcap
. What am I missing?
/sbin
is simply a symlink to/usr/sbin
(seels -l /
) in Ubuntu (and most other distros), so either is correct (and the same) in this case. In other words, this seems to be unlikely to be a solution to the OP's problem. – NotTheDr01ds Sep 14 '23 at 11:05root
or withsudo
is dangerous"? Most all examples that I could find from highly reputable sources usedsudo
. Thanks! – NotTheDr01ds Sep 14 '23 at 11:05Here is a short reference about why you should avoid running tcpdump (and in general any executable) as root if you can avoid it: https://www.securityartwork.es/2012/06/18/tcpdump-drop-privileges-2/
Recent versions of tcpdump seem to have some safeguards when the user runs them as root, since by default they use the
– Foivos Sep 14 '23 at 11:26relinquish-privileges
flag.