Disable/Enable Ping Response in Linux

Linux

Option 1:

Disable Ping:

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

Option 2:

Enable Ping:

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

Disable and enable ping in permanent way

Disable Ping:

Set the following into /etc/sysctl.conf file

net.ipv4.icmp_echo_ignore_all = 1

Reload /etc/sysctl.conf

sysctl -p

Enable Ping:

Set the following into /etc/sysctl.conf file

net.ipv4.icmp_echo_ignore_all = o

Reload /etc/sysctl.conf

sysctl -p