16

I have such trouble when using ping 127.0.0.1 under root:

ping: icmp open socket: Operation not permitted

What does it mean? When I try ls -l /bin/ping it says:

-rwsr-xr-x 1 root root 30788 Jul 27  2010 /bin/ping

I'm using Debian GNU/Linux 5.0

3 Answers 3

16

After few search I found setcap and :

setcap cap_net_raw=ep $(which ping)
4
  • I had that problem with the default installation of SparkyLinux (facepalm). Zulu's solution fixed it.
    – msb
    Commented Aug 10, 2014 at 2:00
  • I had this with a Debian chroot inside an Ubuntu 14.04, and executing this to the debian executable while not chroot'ed fixed it.
    – Vargas
    Commented Nov 3, 2015 at 14:19
  • This fixed the problem on Raspbian 8.
    – user46935
    Commented Jan 1, 2016 at 16:34
  • -bash: setcap: command not found
    – Soonts
    Commented Sep 25, 2019 at 19:09
2

This solution worked for me:

sysctl -w net.ipv4.ping_group_range="0 1000"
1
  • To make this change permanent, create a file such as /etc/sysctl.d/ping.conf (the name can be anything as long as it ends with .conf) containing line net.ipv4.ping_group_range = 0 2147483647 and reload sysctl.
    – Petr
    Commented Jul 6, 2022 at 18:22
1

You might have an iptables rule preventing pings from getting to localhost (this is entirely possible with iptables).

The following will clear all iptables rules. Do this cautiously because iptables is used to implement firewalling on Linux, so you are effectively disabling your firewall.

iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -F
iptables -X

This could happen if your route table is messed up, I believe, as well. Give us the output of route if the above leads nowhere.

The only other thing I can think of is that you have lo, the localhost "virtual network adapter", involved in some weird bridging configuration with another adapter. But this is highly unlikely (but you can use brctl to check).

2
  • I have real IP that's why I don't want to open totally computer to world in case of clearing iptables. ifconfig says besides lo: lo:4 Link encap:Local Loopback inet addr:92.xxx.xxx.xxx Mask:255.255.255.255 UP LOOPBACK RUNNING MTU:16436 Metric:1. brctl not found.
    – Massimo
    Commented May 25, 2011 at 18:41
  • # iptables --list FATAL: Could not load /lib/modules/2.6.34-vs2.3.0.36.30.4.pre8/modules.dep: No such file or directory iptables v1.4.2: can't initialize iptables table filter': Permission denied (you must be root)
    – Massimo
    Commented May 25, 2011 at 18:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .