DebianLinuxTutorials

How To Setup UFW Firewall on Debian 11

Setup UFW Firewall on Debian 11

In this tutorial, we will show you how to setup UFW Firewall on Debian 11. For those of you who didn’t know, UFW is a powerful firewall management tool that simplifies the process of configuring and controlling iptables, the underlying firewall software on Linux systems. Unlike the complex syntax of iptables, UFW provides a straightforward and intuitive interface, making it an ideal choice for both novice and experienced users.

One of the key advantages of UFW over other firewall solutions like nftables is its ease of use. With UFW, you can quickly allow or deny specific services, ports, and IP addresses without delving into the intricacies of iptables rules. Additionally, UFW offers a range of features, including IPv6 support, application profiles, and logging capabilities, ensuring comprehensive protection for your Debian 11 system.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Setup UFW Firewall on a Debian 11 (Bullseye).

Prerequisites

  • A server running one of the following operating systems: Debian 11 (Bullseye).
  • It’s recommended that you use a fresh OS install to prevent any potential issues
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Setup UFW Firewall on Debian 11 Bullseye

Step 1. Before proceeding with the installation of UFW, it’s essential to ensure that your Debian 11 system meets the necessary requirements and is properly configured. First, update your system’s package lists and installed packages by running the following commands:

sudo apt update
sudo apt upgrade

Step 2. Installing UFW Firewall on Debian 11.

By default, UFW Firewall is available on Debian 11 base repository. So, now run the following command below to install UFW on your Debian system:

sudo apt install ufw

Once the installation is complete, now enable UFW (to start automatically upon system boot) and verify the status using the commands below:

sudo ufw status
sudo ufw enable

Step 3. Configure UFW Firewall Rules.

  • Default policies of UFW

Allowing rules is quite simple from the command line, and it is sometimes necessary. For example, by default UFW denies all of the incoming connections, which will make it a problem if you are using SSH. Therefore, you must create a rule which allows SSH connections using the following command below:

sudo ufw allow ssh

Other rules may be added in the same way by simply specifying the name of the program. UFW comes with preloaded defaults for some commonly used programs, and they are automatically activated when you make a rule by specifying the name of the program. If we want to display the list of the applications then we will run the following command:

sudo ufw app list
  • Port Ranges

Port ranges may also be specified, a simple example for TCP would be:

sudo ufw allow 2000:3000/tcp

and for UDP:

sudo ufw allow 2000:3000/udp
  • IP address

An IP address may also be used:

sudo ufw allow from 111.222.333.444

Step 4. Install a Graphical user interface for the UFW firewall.

Those who are using Graphical Desktop Linux can install a graphical user interface for their UFW firewall called “GUFW” (Graphical Uncomplicated Firewall). Run the following command below to install it:

sudo apt install gufw

Setup UFW Firewall on Debian 11 Bullseye

Congratulations! You have successfully configured UFW Firewall. Thanks for using this tutorial for installing the latest version of the UFW Firewall on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official UFW website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button