Documentation Linux VPS Updated

Configuring the firewall with UFW

Install and configure UFW on a Linux VPS to open only the ports you need, with examples of common rules.

On this page
  1. What UFW is
  2. Installing UFW
  3. The basic rule before enabling it
  4. Enabling the firewall
  5. Opening other common ports
  6. Checking the active rules
  7. Removing a rule
  8. Disabling it temporarily

What UFW is

UFW (Uncomplicated Firewall) is a simplified front end on top of the native Linux firewall (iptables/nftables). It lets you define easily which ports accept incoming connections, without handling the more complex iptables syntax directly.

Installing UFW

On Debian/Ubuntu, UFW is usually already present. If it is not:

sudo apt install ufw

The basic rule before enabling it

sudo ufw allow 22/tcp

(Replace 22 with your actual SSH port if you changed it.)

Enabling the firewall

sudo ufw enable

A confirmation is requested, because this command can cut an active connection if the SSH rule has not been added beforehand.

Opening other common ports

sudo ufw allow 80/tcp     # HTTP
sudo ufw allow 443/tcp    # HTTPS
sudo ufw allow 25565/tcp  # example: Minecraft server

Checking the active rules

sudo ufw status verbose

Shows the full list of active rules along with their state (allowed, denied).

Removing a rule

sudo ufw delete allow 80/tcp

Disabling it temporarily

sudo ufw disable

Useful for a one-off diagnosis (working out whether a connection problem comes from the firewall or elsewhere); re-enable it afterwards with sudo ufw enable.

Can’t find your answer? Open a ticket · Discord