Skip to main content
Tutorials

How to Properly Configure Firewall Rules on a Linux Business Server

Learn how to secure your business server by setting up clean, effective firewall rules using UFW to block unwanted traffic and allow only necessary services.

Linux server command line terminal showing active firewall rules in a modern office data center

Introduction to Server Firewalls

When you run a business server, security is always a top priority. Whether your server hosts a website, stores company files, or runs internal applications, keeping unauthorized users out is essential. One of the best ways to protect your system is by configuring a reliable software firewall. For many Linux server solutions, the Uncomplicated Firewall, commonly known as UFW, provides a simple yet powerful way to control network traffic.

Many business owners and system administrators overlook basic firewall configuration, leaving default ports open to potential attackers. By taking a few minutes to set up explicit rules, you can dramatically improve your server safety. In this practical tutorial, we will walk through the steps to install, configure, and manage basic firewall rules on a Linux business server without getting lost in complicated syntax.

Prerequisites for Firewall Configuration

Before you begin making changes to your server security settings, make sure you have the following ready:

  • A running Linux server, such as Ubuntu or Debian.
  • Sudo or root access to run administrative commands.
  • Terminal access via SSH or a direct console connection.

Important Warning: If you are configuring a remote server via SSH, always ensure that your SSH port is allowed before you turn the firewall on. Otherwise, you might lock yourself out of your own system.

Step 1: Check UFW Status and Installation

Most modern Linux distributions come with UFW pre-installed, but it is always good practice to check if it is active. Log into your server and run the following command in your terminal:

sudo ufw status

If the output says that the status is inactive, do not panic. This is normal for a fresh installation. If the tool is not installed on your system, you can easily install it using your package manager, such as sudo apt install ufw.

Step 2: Set Default Policies

Before creating specific rules for incoming and outgoing connections, you should establish a secure baseline policy. The best practice for a business server is to deny all incoming traffic by default and allow all outgoing traffic.

Run these commands to set your default policies:

sudo ufw default deny incoming
sudo ufw default allow outgoing

Setting incoming traffic to deny means that nothing can reach your server unless you explicitly open a port for it. Allowing outgoing traffic ensures your server can still download updates, send emails, and communicate with external APIs.

Step 3: Allow Essential Services

Now that your default policy blocks everything, you need to open doors for the legitimate traffic your business relies on. Always allow your SSH connection first so you do not lose access:

sudo ufw allow OpenSSH

If your server hosts a public website, you will also need to allow standard web traffic on ports 80 and 443:

sudo ufw allow http
sudo ufw allow https

Alternatively, you can specify port numbers directly if you run services on non-standard ports, like this:

sudo ufw allow 8080/tcp

Step 4: Enable the Firewall

Once you have added the rules for your essential services, you are ready to turn on the firewall. Run the activation command:

sudo ufw enable

The system will prompt you with a warning that doing this might disrupt existing SSH connections. Since you already allowed OpenSSH in the previous step, you can safely type y and press Enter to proceed. Verify that the firewall is running by checking its status again:

sudo ufw status verbose

You should see a clear list of your active rules and default policies.

Step 5: Managing and Testing Your Rules

As your business grows, your server needs may change. You might need to add new applications or close ports you no longer use. To view all your rules with their corresponding numbers, run:

sudo ufw status numbered

If you ever need to delete an outdated rule, you can reference its number. For example, to delete rule number three, simply run:

sudo ufw delete 3

Routine review of your firewall rules helps ensure that your server environment remains clean and secure over time.

Partner with NetBit for Reliable Server Solutions

Proper firewall configuration is just one part of maintaining a secure and stable IT infrastructure. If your business needs professional assistance with server setup, network hardening, routine maintenance, or custom server solutions, the technical team at NetBit is here to help you build a secure digital foundation. We invite you to contact us today and become a client for NetBit tech and software house to secure your business operations with expert guidance and dependable technology services.

Discussion

Reader comments.

Share your question, suggestion or experience related to this article.

0 Approved Comments

No comments yet

There are no approved comments on this article yet. You can be the first person to leave one.

Keep Reading

Related insights.

View all articles
WhatsApp