← Back In the print window choose “Save as PDF” as the printer.

UFW Firewall cheatsheet

Protect a Linux machine with a few simple rules

UnixDroid

How it works

  1. A connection arrives — Something tries to reach a port.
  2. Rules are checked — UFW looks for a matching allow or deny rule.
  3. Allowed passes — Trusted services work normally.
  4. Everything else stops — Default deny protects forgotten services.

First steps

sudo ufw default deny incoming
Block incoming by default
sudo ufw allow OpenSSH
Keep remote access
sudo ufw allow 443/tcp
Allow secure web traffic
sudo ufw enable
Switch the firewall on
sudo ufw status verbose
See the rules
On a remote server, add the SSH rule first or you may lock yourself out. Practise only on your own computer, your own network or a lab that gives you permission. Using security tools on systems that are not yours can be a crime (in India under the IT Act).