brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ufw before.rules is where you drop ping replies

Ufw
~/tips/tip-ufw-before-rules-icmp

sudo ufw reload

Edits ufw's rule file to stop the host from answering pings.

ufw has no command for ICMP, because the rules for it sit in a file that ufw reads before your own rules.

sudo sed -i.bak 's/-A ufw-before-input -p icmp --icmp-type echo-request -j ACCEPT/-A ufw-before-input -p icmp --icmp-type echo-request -j DROP/' /etc/ufw/before.rules
sudo ufw reload

ufw reads /etc/ufw/before.rules before your own rules, and it accepts echo requests there by default. The -i.bak flag keeps a copy of the original next to the file. Changing ACCEPT to DROP stops the host from answering IPv4 ping. The IPv6 rules live in before6.rules and need their own edit. Blocking all ICMP can break path MTU discovery on IPv6, so I would only block echo requests, as above.

Further reading: ufw-framework manual page

More Ufw tips sudo ufw app update all sudo ufw show raw sudo ufw allow to 10.0.0.1 proto esp sudo ufw allow to 224.0.0.0/24 from 10.0.0.1 proto vrrp sudo ufw show listening All Ufw tips (32) All topics

Link