Linux : How to disable ICMP echo request

By | January 20, 2013

The easiest way of disabling ICMP echo request on Linux is doing it on the kernel level.

To disable ICMP immediately on a running system, simply enter the following command :

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

This command will not survive to the next reboot. To make it permanent, edit :

vi /etc/sysctl.conf

And add :

net.ipv4.conf.icmp_echo_ignore_all = 1

You can also achieve this through IPtables. Just edit :

/etc/sysconfig/iptables

And add :

iptables -I INPUT -p icmp --icmp-type 8 -j DROP

And for IPv6 :

ip6tables -I INPUT -p icmpv6 --icmp-type 8 -j DROP