Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to block ping (ICMP) requests on your server

This guide shows you how to stop your server from answering ping. It needs root access, so it is for VPS and dedicated server owners.

cPanel2 min read12 steps

What is ICMP?

ICMP is a small helper message system on the internet. The best known use is ping. When you ping a server, you ask, "Are you there?" The server answers, "Yes." These messages are ICMP requests.

Ping is useful. But some people turn it off. It makes the server a little harder to spot. It can also cut down floods of junk ping traffic.

Warning: Blocking ping can confuse monitoring tools. They may say your server is down when it is not. Some support checks use ping too. Take a note of your current firewall settings before you change anything.

Method 1: Use a command

  1. Log in to your server over SSH as root. SSH lets you type commands on the server from far away.
  2. Check that ping works now. From another computer, run ping YOUR-SERVER-IP.
  3. Run this command on the server.
    iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
    This drops all incoming ping requests. Drop means the server ignores them.
  4. Ping the server again from the other computer. It should time out.

This change vanishes after a reboot. To keep it, add the rule to your firewall tool. If your server uses CSF, the next method is better.

Method 2: Use CSF

CSF is a firewall add-on often used with cPanel. Your server may or may not have it.

  1. Log in to WHM.
  2. Search for ConfigServer Security & Firewall.
  3. Click Firewall Configuration.
  4. Find the setting called ICMP_IN.
  5. Set it to 0. This blocks incoming ping.
  6. Click Change at the bottom, then Restart csf+lfd.

How to turn ping back on

  1. For the command method, run
    iptables -D INPUT -p icmp --icmp-type echo-request -j DROP
    This removes the rule.
  2. For CSF, set ICMP_IN back to 1 and restart.
Tip: Ping blocking does not make a server safe on its own. Keep your software updated and use strong passwords.

Quick recap

  • ICMP carries ping messages.
  • You can block them with an iptables rule or with CSF.
  • Monitoring tools may report a false "down" status.
  • Remove the rule to turn ping back on.