How to Setup UFW firewall on Debian 10
Table of Contents
Setup UFW firewall on Debian 10
UFW stands for uncomplicated firewall used to manage firewall rules in Debian. UFW simplifies the process of configuring the firewall. In this tutorial, you will learn how to setup the UFW firewall on Debian.
Before you start to configure UFW on Debian 10. You must have the non-root user account on your server with sudo privileges.
Before You Begin
Install UFW by using the following command
sudo apt install ufw
Set up default policies
Most of the time your system needs to have only some ports open for incoming connections and closed all remaining ports. With UFW you can set these things by using the following commands
To deny all incoming connections type following in the terminal
sudo ufw default deny incoming
To allow all outgoing connections type following in terminal.
sudo ufw default allow outgoing
You can service name or port number to add new rules. It’s very much easier to add rules in UFW. Following is the format to add new rules
sudo ufw ACTION PORT_NUMBER
In the above format, ACTION can be allowed, deny, etc. and PORT_NUMBER is the numeric value.
To Allow incoming and outgoing connection on port 22(SSH) execute the following command
sudo ufw allow 22
Or you can also run
sudo ufw allow ssh
You can deny traffic on a certain port by typing
sudo ufw deny 112
You can delete any of the rules added to ufw by executing the following command.
In the following example, you are going to delete rule which allows connection on port number 80
sudo ufw delete allow 80
Adding advanced rules
To deny connections from specific IP address:
sudo ufw deny from 22.214.171.124
To allow connections from specific IP address:
sudo ufw allow from 126.96.36.199
Checking UFW status
You can check UFW status and all the rules by typing
sudo ufw status
Output should be
Status: active To Action From -- ------ ---- 22 ALLOW Anywhere 80/tcp ALLOW Anywhere 443 ALLOW Anywhere 22 (v6) ALLOW Anywhere (v6) 80/tcp (v6) ALLOW Anywhere (v6) 443 (v6) ALLOW Anywhere (v6)
Enable UFW status
If above sudo ufw status command gives status inactive type following in the terminal
sudo ufw enable
to disable UFW status
sudo ufw disable
Logging in UFW
You can enable or disable logging in UFW. There are three levels for logging in ufw low, medium, high. the default log level is low.
You can enable logging. type following in the terminal
sudo ufw logging on
Here successfully completed the tutorial on how to setup the UFW firewall on Debian 10. If you have any queries regarding this then please don’t forget to comment below.
How to Use Linux Screen Command With Examples
How to Install Opera Browser on Linux Mint 19
How to install phpMyAdmin on Debian 9
How to Find or Search a Word in Vim or Vi Text Editor
How to Install Java on Linux Mint 19
How to Install WebStorm on Manjaro 18
How to Install PostgreSQL on CentOS 7
How to Uninstall Programs from Ubuntu System
How to Create Sudo User on CentOS
How to Install Google Chrome on Linux Mint 19
How to install Audacity on Ubuntu 18.04
How to Install Django Web Framework on CentOS 7