How To Disable & Enable Ping in Linux

Disabling pings on your computer will make it difficult for hackers to pinpoint where you are located and what type of machine is accessing the internet. This article provides steps about how to turn off ping in Linux operating system, so keep reading!

What is Ping on Linux?

Ping is a TCP/IP utility that is used to help identify the presence of a packet-switched network, and can be used to test connectivity from one host on a network to another. Ping sends an ICMP echo request packet to the destination over the network’s defined data path. If the destination host can receive packets from that data path, then it sends back an ICMP echo reply packet.

The ping command in Linux is used to determine whether or not a particular IP address can be reached and if that IP address responds correctly. 

Ping has many uses including determining connectivity problems with cables, routers, firewalls or other equipment; testing basic configuration settings; detecting when computers are running; detecting when there is no response at all; checking for outdated versions of packages installed in remote hosts when using distributed version control systems like Git or Subversion (DVCS); and even blocking some web browsers from accessing services on the internet – due to some privacy concerns.

What is IP Table?

IP tables are a means of selectively allowing or blocking network packets at the network layer, which is the first part of the OSI model. If you want to be able to offer web access but also prevent users from visiting sites that might contain corrupt files or malware, then your local firewall will need to have an IP table configured for it.

The easiest way to block pings on your Linux system is by using the IP tables rules, which are built into all network interface cards. The default table size of 32 should be sufficient for most networking needs, but you can choose to have more or less entries if it suits your specific needs.

All you have to do is load a few kernel modules, create a rule that will block ICMP echo requests and then configure the network interface itself to filter incoming packets.

What is ICMP?

ICMP is an acronym for Internet Control Message Protocol. It is part of the Internet Protocol Suite and used in IP-based internets to send status information, error notifications and also for diagnostics.

When using this approach, the device communicates with another device via an IP network, and errors are sent over the internet. It also informs whether or not the contact was successful when two devices communicate over a different IP address.

Advantages and Disadvantages of Disabling Ping


  • Helps keep your computer from being identified as a potential target for people who attempt a Denial of Service (DoS) attack.
  • If you are on a network and you use the ping command, it will make all hosts on that network “visible” to outside internet users.


How do I Disabling Ping in Linux?

There are many ways to Disable Ping in Linux, just use the methods that work for you.

Install CSF firewall

Edit csf.conf file

vi /etc/csf/csf.conf

Then disable with

ICMP_IN = "0"

You can set to “1” to turn on again.

Use ICMP echo

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

This command works temporary and it resets on system reboot.

Use IP table

iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
iptables -A OUTPUT -p icmp --icmp-type echo-reply -j DROP


There are many ways to Disable Ping in Linux, just use the methods that work for you. Whether it’s using CSF firewall or editing csf.conf file and changing ICMP_IN value of “0” to “1”, there is something out there for everyone. If all else fails, try echo commands which will only be temporary until system reboot occurs again. These approaches should help you get through your day without worry about pings!

Leave a Comment

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

Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.