Skip to content

Install UFW ​

Install and configure UFW firewall on the root server (Ubuntu/Debian)

UFW stands for Uncomplicated Firewall and is a simple frontend for iptables that significantly simplifies the administration of the server firewall.


  1. Update system

    First update the system of your root server. Open the console and enter the following command:

    apt update && apt upgrade -y
    apt update && apt upgrade -y
  2. Install UFW

    Install UFW by entering the following command in the console:

    apt install ufw
    apt install ufw
  3. Check if the installation was successful

    Check whether the installation was successful by entering the following command:

    ufw status
    ufw status

    Default setting after installation: Status: inactive

  4. set default rules

    We recommend blocking all incoming connections and only enabling the required ports:

    sudo ufw default deny incoming
    sudo ufw default allow outgoing
    sudo ufw default deny incoming
    sudo ufw default allow outgoing
  5. Release SSH port (important!)

    Open the default SSH port (port 22) if you need it for remote access to the server:

    sudo ufw allow ssh
    sudo ufw allow ssh

    If your SSH port differs from the default configuration (port 22), use the correct port, e.g. 33

  6. Enable other services (optional)

    HTTP (web server):

    sudo ufw allow http
    sudo ufw allow http

    HTTPS (SSL)

    sudo ufw allow https
    sudo ufw allow https

    Minecraft (default port 25565)

    sudo ufw allow 25565
    sudo ufw allow 25565

    Teamspeak 3 (example)

    sudo ufw allow 9987 # Voice
    sudo ufw allow 10011 # Query
    sudo ufw allow 30033 # File Transfer
    sudo ufw allow 9987 # Voice
    sudo ufw allow 10011 # Query
    sudo ufw allow 30033 # File Transfer
  7. Enable UFW

    Activate the firewall:

    sudo ufw enable
    sudo ufw enable

    Confirm with y when asked. You can then check the status:

    sudo ufw status
    sudo ufw status
  8. Manage rules

    Remove rules (e.g. HTTP port):

    sudo ufw delete allow http
    sudo ufw delete allow http

    Show all rules:

    sudo ufw status numbered
    sudo ufw status numbered

    Disable UFW (if necessary)

    sudo ufw disable
    sudo ufw disable