Disable Ping Response in Linux

Disable Ping Response in Linux

Ping response can be disabled on the server due to many reasons such as server security, to avoid the network congestion., etc. Ping can disabled temporary and permanent in Linux.

Disable Ping response Temporary:

To disable the ping response temporary run the following command on the server as root

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

This will instruct the kernel to ignore the all the ping request. This is temporary method and will be removed after server reboot

To enable the ping response back you can run the following command:

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

Again this is the temporary method of enabling the ping if the ping is set to disabled permanently

Disable Ping Response Permanentaly

To permanently disable the ping response perform the following simple steps:
1. Opne the sysctl.conf file in any text editor:

# vi /etc/sysctl.conf

2. Add the following line at the end of the file:

net.ipv4.icmp_echo_ignore_all = 1

3. Now save the code and exit from the file.
4. Now Execute “sysctl -p” to enforce this setting immediately.

# sysctl -p

After performing the above steps you will notice server no longer responds to your ping responses.