SecurityIntermediate15 min

How to Secure Your VPS with UFW Firewall

Learn how to configure UFW firewall to protect your server from unauthorized access

Introduction

UFW (Uncomplicated Firewall) is a user-friendly firewall management tool for Linux. This guide will help you secure your VPS.

Step 1: Install UFW

Install UFW if it's not already installed on your system.

sudo apt update
sudo apt install ufw

Step 2: Set Default Policies

Configure default policies to deny incoming and allow outgoing traffic.

sudo ufw default deny incoming
sudo ufw default allow outgoing

Step 3: Allow SSH

Allow SSH connections before enabling the firewall to avoid being locked out.

sudo ufw allow 22/tcp

Step 4: Allow HTTP and HTTPS

If you're running a web server, allow HTTP and HTTPS traffic.

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

Step 5: Enable UFW

Enable the firewall and verify the status.

sudo ufw enable
sudo ufw status verbose

Conclusion

Your VPS is now protected by UFW firewall. Remember to allow any additional ports your applications need before enabling the firewall.

#UFW#Firewall#Security#Linux#Ubuntu

Need Help?

If you encounter any issues following this tutorial, our support team is here to help 24/7.