Setting up a firewall: Block ping (ICMP)

To disable remote ping change ACCEPT to DROP in /etc/ufw/before.rules on the following lines:

# ok icmp codes
-A ufw-before-input -p icmp --icmp-type destination-unreachable -j ACCEPT
-A ufw-before-input -p icmp --icmp-type source-quench -j ACCEPT
-A ufw-before-input -p icmp --icmp-type time-exceeded -j ACCEPT
-A ufw-before-input -p icmp --icmp-type parameter-problem -j ACCEPT
-A ufw-before-input -p icmp --icmp-type echo-request -j ACCEPT

To activater logging type:

sudo ufw logging on 

in the terminal

See the Arch wiki for more info: Uncomplicated Firewall - ArchWiki

3 Likes