5

I want to disable ping response all the time on my Ubuntu operating system, the following commands work but these are just until the system reboots:

Ping off:

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

Ping on:

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

How would I be able to leave echo off even when I am rebooting my laptop?

  • Thank you, did not realise there was so many spelling mistakes xd. – HardRebootHackerHD Dec 22 '17 at 8:04
7

How would I be able to leave echo off even when I am rebooting my laptop?

You can use one of the 3 way (as root):

1) Add the following line to your /etc/sysctl.conf

net.ipv4.icmp_echo_ignore_all=1

Then :

sysctl -p

2) Using iptables:

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

3) The cron job way , run crontab -e , then add the following line:

@reboot echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all

Start and enable the service:

systemctl start cron.service
systemctl enable cron.service
  • @HardRebootHackerHD i have update , the cron job should solve your problem. The working command should be executed automatically every reboot. – GAD3R Dec 22 '17 at 8:23
  • All above commands are done, still a ping response when I have rebooted. – HardRebootHackerHD Dec 22 '17 at 8:31
  • 1
    Works for me on CentOS – Kevin Lemaire Dec 22 '17 at 9:27
  • 1
    Just got it working, it was because I needed to do sudo crontab -e as you said. – HardRebootHackerHD Dec 22 '17 at 9:37
  • 1
    You should mention that these are three different ways to achieve it. – dirkt Dec 22 '17 at 10:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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