Closed

Description
ADMIN EDIT
Solution
echo 'net.ipv4.ping_group_range = 0 2147483647' > /etc/sysctl.d/99-ping.conf
sysctl -p /etc/sysctl.d/99-ping.conf
Read more
- https://fedoraproject.org/wiki/Changes/EnableSysctlPingGroupRange
- sysctl: Enable ping(8) inside rootless Podman containers systemd/systemd#13141
- https://github.com/systemd/systemd/blob/master/sysctl.d/50-default.conf
- caec92e
Hi there,
It seems for some reason DietPi is set up in a way where a normal user cannot perform a ping operation?
dietpi@DietPi:~$ ping 192.168.88.14
ping: socket: Operation not permitted
dietpi@DietPi:~$ sudo ping 192.168.88.14
PING 192.168.88.14 (192.168.88.14) 56(84) bytes of data.
64 bytes from 192.168.88.14: icmp_seq=1 ttl=64 time=1.05 ms
Is there a special reason for this or is this a bug?
Metadata
Metadata
Assignees
Projects
Relationships
Development
No branches or pull requests
Activity
Fourdee commentedon Jun 12, 2017
@xanview
Seems permissions need to be set on the ping binary for underpriv users to run this:
https://www.raspberrypi.org/forums/viewtopic.php?p=874479&sid=679670d4747d3e00e7885a18ac71e7f4#p874479
Fourdee commentedon Jun 17, 2017
Marking as resolved, please reopen if required.
gade-raghav commentedon Aug 18, 2018
use the following command.
sudo ping "your ip addr or host name"
Jewsh-S commentedon Sep 18, 2019
Find the location of the ping binary in case it's not normal using "type ping". Then give it privileges to use as non root user "chmod +s /bin/ping" or "chmod +s /location/of/ping"
MichaIng commentedon Sep 19, 2019
Or use this one-liner:This should be actually the default permissions, however we observed much stranger setups in cases 😄.EDIT: The binary is world-executable, hence this is not the issue. The missing capabilities for the binary itself when being executes with unprivileged user is, see possible solution below 👍.
jerinisready commentedon Dec 26, 2019
This seems to be working here
MikeHigginbottom commentedon Jan 13, 2020
This is probably the correct answer.
Doing a
sudo ping <host>
is probably what the kernel developers intended you to do since it's not really supposed to be run by normal users but it's pretty much considered an everyday tool these days and sudoing every time is a bit of a pain.Adding the 'setuid' bit with
chmod +s /bin/ping
is what most Linux distros seem to do but it's a bit of a security concern because it grants ALL the rights of a super user.The
setcap
approach grants much more restricted rights by only allowing it the specific capabilities it needs.MichaIng commentedon Jan 13, 2020
@MikeHigginbottom
Thanks for explaining this a bid. Yes granting only the specifically required capabilities.
I just checked what is default on Debian:
This seems to be sufficient, since I can ping which any unprivileged user. Of course the
iputils-ping
ships several more feature than performing simple ping, probably for one of thosecap_net_admin
is required.MikeHigginbottom commentedon Jan 13, 2020
Mmm. Suspect you're right about cap_net_admin. I can ping localhost from my sandbox iputils build on Ubuntu without it.
OT but... Interestingly Ubuntu does the setuid thing rather than using capabilities which is weird considering what you're seeing on Debian. Maybe the Ubuntu devs made a conscious decision to override the Debian choice and use setuid for some reason?
MichaIng commentedon Jan 14, 2020
@MikeHigginbottom
No idea why Ubuntu handles it differently. Perhaps it is simply a failsafe step to assure that it can do all it needs for all features/options it has. In the end, if you trust the ping binary, and everyone can check the source code, then you can grant it super user permissions. I am just conservative here, also to prevent from bugs, human errors, very unlucky file corruptions or whichever thinkable thing 😉.
datdinhquoc commentedon May 28, 2020
using sudo works, but my user is already in 'wheel' group ('sudo' group); i just can't guess out why i need sudo, any ideas?
MichaIng commentedon May 29, 2020
The sudo/wheel group only allows you to call sudo, but it does not replace the sudo call. Either you need to use sudo or you need to grant the binary itself the capabilities as mentioned here: #1012 (comment)
datdinhquoc commentedon May 29, 2020
i can ping without sudo now (suggested by Jewsh-S above):
sudo chmod +s /usr/bin/ping
ping google.com
13 remaining items