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 raw prints the complete firewall as iptables rules

Ufw
~/tips/tip-ufw-show-raw

sudo ufw show raw

Shows everything ufw has actually loaded, which is handy when a rule does not behave as expected.

ufw status shows the rules I typed. When traffic is blocked and the status list looks fine, I want to see what is really loaded. That is what ufw show is for.

sudo ufw show raw

The man page says the raw report shows the complete firewall, and the other reports show a subset of it. The reports you can ask for are raw, builtins, before-rules, user-rules, after-rules, logging-rules, listening and added.

sudo ufw show user-rules
sudo ufw show before-rules

If you only want to read the rules from your own ufw allow and ufw deny commands as the firewall holds them, user-rules is much shorter than raw. before-rules is the place to look when you have edited /etc/ufw/before.rules and want to know whether your change arrived.

One caveat: the man page says each report is based on the live system and, except for listening, is in raw iptables format. So you need a bit of iptables reading skill, and the output can be long. A pipe into less or grep helps. The listening and added reports are different, they show listening ports with the rules that may affect them, and the rules as you added them on the command line.

Further reading: ufw man page

More Ufw tips sudo ufw app update all 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