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

slhck
  • 228,104
Massimo
  • 171
  • 1
  • 2
  • 6

3 Answers3

16

After few search I found setcap and :

setcap cap_net_raw=ep $(which ping)
Zulu
  • 262
1

This solution worked for me:

sysctl -w net.ipv4.ping_group_range="0 1000"
Shōgun8
  • 198
  • 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 Jul 06 '22 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).

LawrenceC
  • 73,957
  • 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 May 25 '11 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 May 25 '11 at 18:44