How can I manage my Ubuntu machine so it doesn't (or does) respond to PING (ICMP ECHO_REQUEST - type 8) requests?

Normally almost all computers in a LAN network respond to ping with an ICMP ECHO_REPLY, but how to turn it off?

How to manage it? How to manage other types of ICMP requests?

share|improve this question

Another option (not using a firewall) is to set a Linux kernel option.

As most things are accessed as files in Linux, kernel settings are mapped into the special /proc file system

echo 1 | sudo tee /proc/sys/net/ipv4/icmp_echo_ignore_all

you can also make this permanent by setting the value in the file /etc/sysctl.conf:

net.ipv4.icmp_echo_ignore_all = 1

then execute sysctl with -p flag to activate

sudo sysctl -p
share|improve this answer

You can this through two methods: using ufw or iptables.

Using UFW

You need to add:

-A ufw-before-input -p icmp --icmp-type echo-request -j DROP

to:

/etc/ufw/before.rules

then run:

sudo ufw disable
sudo ufw enable

Using iptables

Add the following rules:

iptables -A OUTPUT -p icmp -o eth0 -j ACCEPT          
iptables -A INPUT -p icmp --icmp-type echo-reply -s 0/0 -i eth0 -j ACCEPT     
iptables -A INPUT -p icmp --icmp-type destination-unreachable -s 0/0 -i eth0 -j ACCEPT  
iptables -A INPUT -p icmp --icmp-type time-exceeded -s 0/0 -i eth0 -j ACCEPT       
iptables -A INPUT -p icmp -i eth0 -j DROP
share|improve this answer
    
How do I configure a machine to respond or not respond to ping requests? Which one did you explain? – Steven Roose Oct 12 '17 at 14:45

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.