I have a openvz linux vps and am trying to disable requests to 'ping' to my VPS. How can i do this?
-
2I hope you're not doing this because of "security" - ICMP echo is harmless, useful as a diagnostic tool and as far as DDoS attack vectors go is one of the least effective.– Hubert KarioDec 4, 2010 at 12:36
-
On top, ICMP has a usefull side feature so you are efficiently sabotaging parts of the IP stack. You basically disable PathMTU functionality.– TomTomOct 24, 2013 at 20:14
4 Answers
You can use iptables rules to achieve this:
iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
Add the following line to your init script for the network (the name depends on the distribution you use):
echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all
This disables ping responses.
To reenable, use the following command:
echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all
To make this permanent set the following into /etc/sysctl.conf (if you have such a file)
net.ipv4.conf.icmp_echo_ignore_all = 1
Simplest method of disabling ping response is to add an entry in /etc/sysctl.conf file. If the Iptables flushes or stop server will start responding to ping responses again. I suggest the following entry in your /etc/sysctl.conf file
net.ipv4.icmp_echo_ignore_all = 1
this will tell kernel to not respond any ping response, after this run sysctl -p on shell to implement the changes without reboot.
For more info please refer: http://www.trickylinux.net/disable-ping-response-linux/
You need iptables (or something similar) that blocks ICMP. http://www.cyberciti.biz/tips/linux-iptables-9-allow-icmp-ping.html