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 app update --add-new loads a changed app profile into the firewall

Ufw
~/tips/tip-ufw-app-update-add-new

sudo ufw app update all

After you edit or create a ufw application profile, this command makes the firewall use the new version.

I like ufw application profiles because ufw allow "Nginx Full" is easier to remember than a pile of port numbers. What I’d forget is that editing a profile file does nothing to rules that already exist. ufw has a command for that.

sudo ufw app update "My App"
sudo ufw app update --add-new "My App"
sudo ufw app update all

The man page says that after creating or editing an application profile you run ufw app update <name>, and the firewall is updated with the new profile information. Pass all instead of a name and every profile is updated. Profiles are small INI-style files with title, description and ports fields, so changing the ports line is a typical edit.

The --add-new flag goes one step further: it also adds a rule for a profile that is new. Whether that happens depends on the default application policy, which you set with this command:

sudo ufw app default skip
sudo ufw app default allow
sudo ufw app default deny

The default is skip. With skip, app update --add-new does nothing, so a new profile never opens a port behind your back. With allow or deny the firewall gets a rule automatically. The man page itself warns that a default allow for application profiles may be a security risk, and I agree with it. I’d leave the default on skip and add rules by hand.

Check the result with sudo ufw status verbose, and put the profile name in quotes when it contains spaces.

Further reading: ufw man page

More Ufw tips 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 grep IPV6 /etc/default/ufw All Ufw tips (32) All topics

Link