Blocking ping responses from the system can prevent a system from hackers to ICMP flood DOS attacks. So it can be a best practice for system security but most of the online monitoring systems use ping requests for the monitoring system.
Disable Ping using iptables
You can simply block ICMP responses directly from the firewall (iptables) in any Linux systems.
iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
Block Ping with Kernel Parameter
We can also block ping responses from the system by directly updating kernel parameters. In this, we can block ping responses temporarily or permanently as below.
Block Ping Temporarily
You can block temporarily block ping responses temporarily using following command
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
Block Ping Permanently
In place of blocking ping temporarily, You can block it permanently by adding the following parameter in /etc/sysctl.conf configuration file.
net.ipv4.icmp_echo_ignore_all = 1
Now execute the following command to apply settings immediately without rebooting the system.