Block Ping from a specific IP

12,816

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:
12,816

Related videos on Youtube

Shota Chinchaladze
Author by

Shota Chinchaladze

Updated on September 18, 2022

Comments

  • Shota Chinchaladze
    Shota Chinchaladze over 1 year

    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