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).


  • 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 is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button