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 insert 1 puts a deny rule above your allow rules

Ufw
~/tips/tip-ufw-insert-rule-position

sudo ufw insert 1 deny from 203.0.113.7

Adds a rule at a chosen position so it is evaluated first.

ufw checks rules from the top and the first match wins. A new deny rule added at the end of the list may never be reached.

sudo ufw insert 1 deny from 203.0.113.7
sudo ufw status numbered

insert N places the rule at position N and moves the others down. That is how you block one address that would otherwise match a broad allow rule, such as an open web port. ufw status numbered confirms the order. A plain ufw deny appends the rule to the end, which is too late if an allow rule above it already matches the same traffic.

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