Ping: How to turn off ICMP ECHO Response on Linux Server

Kernel parameters provide a mechanism to adjust the functioning of the Linux kernel. The sysctl command can be used to view and set kernel parameters, and ping response can also be denied by just changing the kernel parameter value. Let’s check the current value of kernel parameter,

# sysctl net.ipv4.icmp_echo_ignore_all

Most likely it will show zero which means your system will request and normally respond to pings. So now by changing the value of kernel parameter net.ipv4.icmp_echo_ignore_all from 0 to 1 will prevent other hosts from successfully pinging your server while not affecting your ability to ping other servers in the network.

To change the kernel parameter value,

# sysctl -w net.ipv4.icmp_echo_ignore_all=1

So now even if you try to ping your network address from your host, it should not work because by changing the kernel parameter value we told the kernel not to respond any ICMP ECHO request.

The changes we made are temporary because sysctl command made the changes in /proc filesystem so if you want the changes to persist across reboots, you need to put the below entry in /etc/sysctl.conf file.

To add the entry in sysctl.conf run,

# echo "net.ipv4.icmp_echo_ignore_all=1" >> /etc/sysctl.conf

Please provide any feedback using the comments below, and I invite you to check out following posts.