In this guide, we will install and set up the Firewall with UFW on Debian 11.
How To Install a Firewall with UFW on Debian 11
The UFW has been available by default in Debian since 10. In Debian 11 you can install it through a simple command:
How To Setup a Firewall with UFW on Debian 11
Before starting the configuration of UFW enable the IPv6 on your Debian system to ensure the UFW manages firewalls for IPv6 in addition to IPv4. To configure this, open the file via the following command:
In the file locate the IPV6 and ensure the value is yes. Save the file and UFW is enabled for both IPV6 and IPV4.
By default, the UFW is set to deny all the incoming connections and allow all the outgoing connections. To enable the incoming connection first you need to create rules that allow the incoming SSH or HTTP connections.
To allow your server incoming ssh connections run the following command:
To allow the HTTP connection run the following command:
How to Enable UFW on Debian 11
To enable the UFW on Debian 11 run the following command, you will be prompted that says the enabling ufw might interpret the existing ssh connection, enter yes:
The firewall is now active on your system, run the verbose command to check all the rules you have set for your system:
How to Configure All UFW Incoming and Outgoing Connections on Debian 11
To deny all the incoming connections run the following command:
To allow all the incoming connections use the allow options:
To allow all the outgoing connections execute the following command:
Run the following command to deny all the outgoing connections:
The firewall is now configured on Debian 11, allowing only those connections that your server needs and limiting unnecessary connections.
How to Disable the Firewall on Debian 11
If you no longer want to use the UFW, you can disable it through the following command:
You can use the reset command to start over again in the ufw:
UFW is a powerful firewall tool also known as an uncomplicated firewall to improve the security of Linux systems. The main purpose of the UFW is to keep a check on the network connections. It keeps track of all the incoming and outgoing connections and only those connections can access the network that is allowed by the firewall. In this detailed guide, we have provided the steps to install and set up the firewall with UFW on Debian 11.