UFW - The Simple Way to Stay Safe

Security is not an option, but a fundamental requirement. UFW (Uncomplicated Firewall) was created to make the complex iptables rules of Linux systems understandable and manageable for everyone, without compromising security.

1. Default Policies

Before adding any rules, we need to establish the basics. The safest approach is to block all incoming traffic and allow all outgoing traffic.

  • To protect your system against external attacks, use the following command:

    sudo ufw default deny incoming
  • To allow browsing and updates:

    sudo ufw default allow outgoing

2. The Most Important Commands (With Examples)

  • Enabling SSH (Critical!): If you manage the machine remotely, this is the first thing to do before activating the firewall, otherwise you will be locked out:

    sudo ufw allow ssh
  • Activating the Firewall: Once your rules are set, you must explicitly enable UFW (it is disabled by default):

    sudo ufw enable
  • Web server traffic:

    sudo ufw allow http

or

sudo ufw allow 80/tcp
  •    Checking status:

    sudo ufw status verbose

3. Graphical interface: GUFW

For those who prefer a mouse over a keyboard, there’s GUFW.

More information