Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am practicing with iptables and... I need a rule that will block a certain host from pinging me but will let me to ping the host if needed (so I need to accept ping responses right?). Can you help me?

share|improve this question
Some context, please. What is your current iptables ruleset (the output of iptables-save) ? – Steven Monday Dec 5 '10 at 0:00

You can block ping (icmp echo requests) from all hosts using this

iptables -I INPUT -j DROP -p icmp --icmp-type echo-request

If you want to block a particular host then

iptables -I INPUT -s -j DROP -p icmp --icmp-type echo-request
share|improve this answer

Allow single ip using

iptables -A INPUT -s x.x.x.x -p ICMP --icmp-type 8 -j ACCEPT

Now drop ICMP packets from rest

iptables -A INPUT -p ICMP --icmp-type 8 -j DROP


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.