How to disable Ping response in Ubuntu

This post was written by admin on June 20, 2010
Posted Under: General

If you want to disable ping response in your ubuntu to protect your machine.You can try following commands in terminal.

First of all,open up a terminal window from Applications->Accessories menu and run this to get super user privilege:

sudo -i

Then:
Method 1:
run this command to disable ping response:

echo  1  > /proc/sys/net/ipv4/icmp_echo_ignore_all

and you can type this to re-enable:

echo  0  > /proc/sys/net/ipv4/icmp_echo_ignore_all

Method 2:
run this to disable ping response:

iptables  -I  INPUT  -i  ech0  -p   icmp  -s  0/0  -d  0/0   -j  DROP

and this to allow ping response:

iptables  -I  INPUT  -i  ech0  -p   icmp  -s  0/0  -d  0/0   -j  ACCEPT

Hope this help!

Related posts:

  1. Ubuntu using Ramdisk for better performance and fast response
  2. Optimize the Usage of Swap to Speed up Response for Ubuntu
  3. Enable and Disable Notebook PC’s touch tablet in Ubuntu
  4. How to Clear and Disable Totem’s recent history in Ubuntu 11.04 Unity
  5. Clear and Disable Recent Documents list on ubuntu gnome

    Reader Comments

    Is the iptables method permanent?

    [Reply]

    #1 
    Written By jordanwb on June 21st, 2010 @ 6:31 am

    Similar but drops echo-requests for the local network.

    iptables -A INPUT -p icmp –icmp-type echo-request -s 192.168.1.0/24 -d 192.168.1.0/24 -j DROP

    [Reply]

    #2 
    Written By an0n on June 21st, 2010 @ 10:38 am

    neither method is permanent unless you already have some mechanism that saves your iptables and restores them on reboot.

    method 1 can be made permanent by editing the /etc/sysctl.conf file so that the setting gets picked up at boot time.

    net.ipv4.icmp_echo_ignore_all=1

    [Reply]

    #3 
    Written By mirradric on June 21st, 2010 @ 10:42 pm

    Add a Comment

    required, use real name
    required, will not be published
    optional, your blog address