Linux: How to disable ping replies?
You may want to disable ping replies for many reasons, maybe for a security reason,
or to avoid network congestion. To disable ping replies, you can do it either with help of
iptables (allow or block ICMP ping request) or by setting the kernel variable.
Temporarily Disable ping replies
To temporarily (will be back after reboot) disable the ping reply, use this command:
su - echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all # This instructs the kernel to simply ignore all ping requests # 1 -- ignore ping requests # 0 -- don't ignore
iptables -A INPUT -p icmp -j DROP
Permanently Disable ping replies
To disable ping requests permanently, add this line into your
net.ipv4.icmp_echo_ignore_all = 1
sysctl's policy by
# sysctl -p.
iptables rule by
# for distros with systemd /usr/libexec/iptables.init save # for all other distros service iptables save # univeral way: edit main config by yourself vim /etc/sysconfig/iptables