Pcornel
Linux · Linux Firewall

UFW

Cheat sheet · https://pcornel.dk/topic.php?topic=2812

Back to the Topic

Answer

UFW (Uncomplicated Firewall) is Ubuntu's simple front end for netfilter: default policies plus allow/deny rules by port, service profile and source.

Remember

Allow SSH before ufw enable. Rules are evaluated in order — ufw status numbered shows it. Docker publishes ports through its own iptables rules that bypass UFW's INPUT rules.

First checks

  • nft list ruleset — all nftables rules
  • iptables -S; iptables -t nat -S — iptables rules (if used)
  • firewall-cmd --list-all — firewalld zone settings
  • ufw status verbose — UFW rules and defaults
  • ss -tulpn — which services listen

Verify in this order

ufw rules → rendered into netfilter chains → packet matched in order → default policy if none

Where it usually breaks

First mismatch in link/interface → address/namespace → route/neighbor → firewall/policy → socket/daemon → DNS/TLS/SSH/application peer path; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2812

Confirmation

Confirm action

Continue?