8

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
10

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
  • All above commands are done, still a ping response when I have rebooted. – HardRebootHackerHD Dec 22 '17 at 8:31
  • Say's "active" and I just followed your recent updated commands and still nothing, could it be due to my kernel-headers not being updated or is that a diffrent thing. – HardRebootHackerHD Dec 22 '17 at 8:44
  • 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 agree to our terms of service, privacy policy and cookie policy

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