How to Completely Disable Ping (ICMP Echo) Requests in Linux to Hide from Scanners

When a hacker or a malicious botnet wants to attack a network, they do not blindly fire exploits into the void. Their first step is always “reconnaissance.” They use automated tools (like Nmap or standard ping sweeps) to rapidly fire ICMP Echo Request packets at millions of IP addresses.

By default, if a Linux server receives an ICMP Echo Request, its kernel politely responds with an ICMP Echo Reply (a “pong”). This seemingly harmless response instantly alerts the hacker: “Yes, there is a live, active computer sitting at this exact IP address.” Once they know you exist, they will begin port scanning your server for vulnerabilities.

To massively reduce the surface area of your server, you should configure it to “drop” ICMP requests. When a scanner pings your IP, the server will remain completely silent. To the automated botnet, your IP address will look like a dead, empty void, and it will usually move on to an easier target.

Step 1: Perform an Immediate Hot Fix

You can instruct the Linux kernel to instantly ignore all ICMP Echo Requests by injecting a command directly into the running memory via sysctl.

  1. Log into your Linux server and open a terminal.
  2. Execute the following command as root:
    sudo sysctl -w net.ipv4.icmp_echo_ignore_all=1

The change is instantaneous. If you open a terminal on your personal laptop and type ping [your-server-ip], you will instantly see “Request timeout.” The server is officially invisible to ping sweeps. However, this change will be completely erased the moment the server reboots.

Step 2: Permanently Disable Ping in sysctl.conf

To ensure your server remains “stealthed” permanently across reboots, you must hardcode the rule into the primary kernel configuration file.

  1. Open the configuration file using a text editor (like nano):
    sudo nano /etc/sysctl.conf
  2. Scroll to the absolute bottom of the file.
  3. Paste the following exact line:
    net.ipv4.icmp_echo_ignore_all = 1
  4. Press Ctrl+O then Enter to save the file.
  5. Press Ctrl+X to exit the nano editor.

Step 3: Commit the Changes to the Kernel

To force the operating system to read the file you just edited and commit it to the active kernel architecture without requiring a hard reboot, run the following command:

sudo sysctl -p

The Result

Your server is now permanently shielded from basic ICMP reconnaissance. It is important to note that disabling ping does not make your server invincible; if you have a web server running on Port 80, a hacker can still find it by scanning Port 80 specifically. However, because 90% of automated botnets rely on a rapid ICMP ping sweep to quickly map a subnet before attacking, remaining completely silent drops you off the radar of the vast majority of low-effort, automated attacks.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.