Skip to content
BENIBIX Learn

Uncomplicated Firewall (UFW)

Infrastructure⌨️ Linux & the Command LineFirewall Tools

Also known as UFW, ufw Command, Ubuntu Firewall

A small firewall tool on Ubuntu. You type short rules like allow 22.

Think of it like

Think of it like a light switch for a hard machine. You press easy buttons, and it does the hard part.

Example

Lucy sets up a new web server. She allows SSH and HTTPS with UFW, then turns it on.

Why it matters

It turns firewall work into a few short lines. So you can close each port the server does not need.

Definition

UFW is a simple firewall tool that comes with Ubuntu. Its name is short for Uncomplicated Firewall. You give it short rules, like allow 22. It turns them into the longer rules the system needs underneath. It is off when Ubuntu is first installed, so you must turn it on yourself.

Example code

console
$ sudo ufw allow 22/tcp
Rules updated
Rules updated (v6)
$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup
Allow SSH first, then turn the firewall on. UFW warns before it might cut you off.
UFW sits on top. You write the short rule, and the layers below do the real filtering.

Common mistake

Turning UFW on before allowing SSH. Your own login is then blocked, and you are locked out.

Key takeaways

  1. 1
    Short rules. allow, deny, then a port.
  2. 2
    Off at first. You turn it on yourself.
  3. 3
    SSH before enable. Or you lock yourself out.

Compare

Learn it properly