Skip to content

How to Block Ping (ICMP) Responses in Linux

Advertisement

Blocking Ping (ICMP) responses in Linux can be an effective way to improve security and reduce unnecessary network traffic. Ping is a commonly used network diagnostic tool that sends a packet to a network device and waits for a response. By default, Linux systems respond to Ping requests, but you can disable this feature using the following steps.

Step 1: Check if ICMP is enabled

Before you proceed with the steps, you need to check if ICMP is enabled on your system. To do this, open a terminal and type the following command:

sysctl net.ipv4.icmp_echo_ignore_all 

If the output is net.ipv4.icmp_echo_ignore_all = 0, it means that ICMP is enabled, and you can proceed with the next steps.

Step 2: Disable ICMP responses

To disable ICMP responses, you need to edit the sysctl.conf file. This file contains system-wide settings that are loaded during boot time. Open the file in a text editor with root privileges:

sudo nano /etc/sysctl.conf 

Add the following line at the end of the file:

Save the file and exit the editor. Then reload the sysctl settings with the following command:

sudo sysctl -p 

This will apply the new setting immediately. From now on, your Linux system will not respond to Ping requests.

Step 3: Verify the changes

To verify that the changes have been applied, try to Ping your Linux system from another device on the network. If the Ping command returns no response, it means that ICMP has been successfully disabled.

Conclusion

Disabling ICMP responses in Linux can be a useful security measure to prevent network attacks and reduce unnecessary traffic. By following the steps outlined above, you can easily block Ping requests and improve the security of your system.

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

5 Comments

  1. this will block all the icmp request even if i add my legitimate ip into the truested zone. cloud you please guide how to allow specific ip address using firewalld not iptables.

  2. i am using centos 7 . i want to disable icmp ping in my centos machine.
    and i already apply those command Disable Ping using iptables..but not works!!

    i want to solution..
    Thanks.

  3. Hi, i disabled ping using this command chain “# iptables -A INPUT -p icmp –icmp-type echo-request -j DROP”, how can i enable it back?

    Thanks,

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top