New

EmeraldHost 2.0 is here: faster, more intuitive, and made for everyone - the new panel!

Learn more
Guides

How to Install UFW on Your Linux VPS

Install and configure UFW firewall on a Linux VPS (Ubuntu/Debian)

2 min read
May 12, 2025

UFW (Uncomplicated Firewall) is a simple frontend for iptables that significantly simplifies the management of your server firewall.

Install UFW

  1. Update system
    First, update the package lists:

    sudo apt update
    
  2. Install UFW
    Install UFW with the following command:

    sudo apt install ufw -y
    

Configure UFW

  1. Set default rules
    Block all incoming connections and allow all outgoing:

    sudo ufw default deny incoming
    sudo ufw default allow outgoing
    
  2. Allow SSH port
    Allow the SSH port so you can still connect:

    sudo ufw allow ssh
    
  3. Allow additional ports (optional)
    Allow additional ports as needed:

    # Web server
    sudo ufw allow http
    sudo ufw allow https
    
    # Minecraft (default port 25565)
    sudo ufw allow 25565
    
    # TeamSpeak 3
    sudo ufw allow 9987/udp    # Voice
    sudo ufw allow 10011/tcp   # Query
    sudo ufw allow 30033/tcp   # File Transfer
    
  4. Enable UFW
    Activate the firewall:

    sudo ufw enable
    

    Confirm with y when prompted.

  5. Check status
    Verify that UFW is running correctly and which rules are active:

    sudo ufw status
    

Manage rules

Show all rules with numbers:

sudo ufw status numbered

Remove a rule (e.g. HTTP):

sudo ufw delete allow http

Block a specific port:

sudo ufw deny 8080

Disable UFW:

sudo ufw disable
Written byEmeraldHost Team
Last updated on Mar 16, 2026 Edit on GitHub

Did this article help you?

Your feedback helps us improve our guides.

Help shape the guides

€10.00 in credit for every new guide, €5.00 for every improvement.

Contact Support

Create a support ticket and our team will get back to you as soon as possible – personal and professional.

Go to Support
1257 members online

Discord Community

Connect with other players, get quick help from the community, and stay up to date with the latest news.

Join Discord

Join our Discord community 1257 members online right now