Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am on a private LAN 192.168.1.0/24. My ip is 192.168.1.3, I want to block only ping requests from 192.168.1.2. I am running ubuntu 11.10. I found two links

First tells how to block an IP but not how to block only ping requests.
Second tells how to disable ping all together.

Can someone please tell me how to block only ping requests from a specific IP

share|improve this question

1 Answer 1

up vote 7 down vote accepted

Using iptables is an exellent choice it's a very powerfull firewall feature built in to the Kernel

as root or with sudo:

iptables -A INPUT -s 192.168.1.100 -p icmp -j DROP

will block all ping(icmp requests) from a the specified IP.

The following to block all ICMP:

iptables -A INPUT -p icmp -j DROP

Basically omitting the ip will bock ALL ping requests.

to remove the following active firewall rule:

iptables -A INPUT -p icmp -j DROP

change the -A (append) to -D (delete)

iptables -D INPUT -p icmp -j DROP

But do you have a good reason to block ICMP? Usually ICMP is a good thing. It is used for MTU discovery etc. Basically making sure that you will have a optimized network/Internet experience.

More info on why you shouldnt block ICMP here

share|improve this answer
    
+1 for why you shouldn't block ICMP. –  zigg Jun 24 '12 at 12:44

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.