Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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 192.168.1.139 -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

Reference http://www.trickylinux.net/ping-single-ip-linux/

share|improve this answer

Your Answer

 
discard

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.