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 delete allow 80/tcp removes a rule by repeating it

Ufw
~/tips/tip-ufw-delete-rule-by-spec

sudo ufw delete allow 80/tcp

Removes a firewall rule by naming it rather than looking up its number.

Numbers in a list change after each delete. Repeating the rule you wrote is more predictable.

sudo ufw allow 80/tcp
sudo ufw delete allow 80/tcp

Put delete in front of the exact rule you added and ufw removes the matching one, for both IPv4 and IPv6. This is easy to use in a script, where there is no way to read a number from the list. The text must match the original rule: allow 80 and allow 80/tcp are separate entries. Run ufw status afterwards to confirm that nothing similar remains.

Further reading: ufw 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