How to Disable Ping Response (ICMP echo ) in Linux?

Disable Ping response
A ping is a signal sent to a host that requests a response. Sometimes, we need to disable the ping response. This article will help you to learn how to disable ping response ( ICMP echo ) in Linux?

Time to learn how to disable ping in Linux.

You can’t avoid this step if you are doing a server hardening.


Method 1

Run the following command to disable the ping request to your server.

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


This is a temporary method to disable ping. This will erase after reboot. To make it permanent, follow the steps given below.

Add the following lines to /etc/sysctl.conf

net.ipv4.icmp_echo_ignore_all = 1


Now update the changes using the following command.

sysctl -p


That will disable incoming ICMP Requests or PIng requests in your system.


Method 2

You can also do the same using Iptables. Please run the below command if you want to disable the ping request using IPtables.

iptables -A INPUT -p icmp -j DROP


Now save the firewall rules by executing the following command.

/etc/init.d/iptables save


You just disabled incoming ping using the firewall.


Method 3

( You only have to check this section if you have a CSF firewall installed )

Most of you may have a CSF firewall installed. If you want to know how to install CSF, please refer to the article –How to install CSF in Linux? It is easy to disable incoming ping using CSF. Find the steps below.

Edit the CSF main configuration file.

vi /etc/csf/csf.conf


You can find the below lines.

# Allow incoming PING
ICMP_IN = "1"


Change it as follows to disable ping.

ICMP_IN = "0"


Now restart CSF and LFD to update the changes.

/etc/init.d/csf restart
/etc/init.d/lfd restart
csf -r


That’s how you Disable Ping in Linux using CSF.

Share this post

Services to Explore

Stay up to date!

Stay up to date with the Web Hosting, Cloud and Server Management Industry News and Tutorials!

We will send you only the relevant emails, and we respect your privacy. Please review our privacy policy for more info.

Linux Management Services

Focus on your business, and let us take care of your Linux Servers!
From what you are reading, it seems you are interested in Linux and related technologies. If you have a moment to spare, please take a look at our Linux Management Services plan, which might interest you even more!
Linux Management Plan

Value-Added Services

We have services that can help you run a successful business. With us, you don't have to worry about these areas because our experts will take care of it for you.

ServerHealers uses cookies.