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 show added lets you check your rules before you enable the firewall

Ufw
~/tips/tip-ubuntu-ufw-show-added

sudo ufw show added

Lists the firewall rules you have added so you can check them before turning ufw on.

Turning on a firewall over SSH has a moment of doubt in it. Did I add the SSH rule, or just think about it?

sudo ufw show added

The man page describes the added report as the rules as they were entered on the command line. It does not show the running firewall, which is exactly why it helps before ufw enable. You see your intent on one screen.

My order of operations on a fresh server: add the rules, check them, enable.

sudo ufw allow OpenSSH
sudo ufw show added
sudo ufw enable

If the SSH line is missing, I have saved myself from a locked door. On a machine I cannot walk up to, that is worth ten seconds. By default ufw denies incoming and allows outgoing once it is on, so anything not on the list is gone.

Because the report reads your intent and not the live state, it also works as a quick review of a rule set you wrote some time ago.

Caveat: ufw may normalize rules, so what it prints can look a bit different from what you typed. Same meaning, different spelling. Use ufw status verbose after enabling to see the active state.

Further reading: ufw(8) man page (Ubuntu 24.04), On this site: ufw limit slows down anything hammering your SSH port, On this site: ufw status numbered lets you delete a rule by its number

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