How to Set Up a Basic Firewall on Ubuntu Using UFW

  • March 13, 2025
  • 0 Comments

A firewall is like a security guard for your server, deciding who can come in and who can't. Setting up a basic firewall on Ubuntu is easy with UFW (Uncomplicated Firewall). Let's see how!

What You'll Need:

  • An Ubuntu server (like one from Hostaira!)
  • SSH access to your server
  • A little bit of caution!

 

Step 1: Update Your Server

First, make sure your server is up-to-date. Open your terminal and type:

sudo apt update && sudo apt upgrade -y

Step 2: Install UFW

UFW is usually installed by default, but let's make sure. Type:

sudo apt install ufw -y

Step 3: Allow SSH Connections

Before enabling the firewall, we need to allow SSH connections so you don't lock yourself out! Type:

sudo ufw allow OpenSSH

Step 4: Allow HTTP and HTTPS Connections (if needed)

If you're running a website, you'll need to allow HTTP (port 80) and HTTPS (port 443) connections. Type:

sudo ufw allow http
sudo ufw allow https

Step 5: Enable UFW

Now, let's turn on the firewall! Type:

sudo ufw enable

You'll see a warning message. Type "y" and press Enter to confirm.


Step 6: Check UFW Status

To see if the firewall is running and what rules are in place, type:

sudo ufw status verbose

Important Tips:

  • Be careful when changing firewall rules!
  • Only allow the connections you need.
  • If you have any questions, Hostaira support is ready to help! Just click here to submit a ticket

 

That's it! You've set up a basic firewall on your Ubuntu server.

How helpful was this article to you?

Posting has been disabled.