How to disable responses to PING [closed]

Solution 1:

To disable the PING response, add the following line to your init script for the network:

echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all

To reenable the PING response do this:

echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all

Update:

To make the change permanent add the following line to /etc/sysctl.conf:

net.ipv4.icmp_echo_ignore_all=1

Solution 2:

It is better to use firewall for these purposes, so that you can optionally enable ping from some systems, esp monitoring systems

iptables -t filter -I INPUT -p icmp --icmp-type echo-request -s monitoring_system -j ACCEPT
iptables -t filter -I INPUT -p icmp --icmp-type echo-request -j DROP