How to Set up UFW Firewall on Ubuntu

Today we focusing How to Set up UFW Firewall on Ubuntu.
How to Set up UFW Firewall on Ubuntu

This article is about how to Set up up UFW Firewall in Ubuntu. A firewall is a tool for monitoring and filtering incoming and outgoing network traffic. It works by defining a set of security rules that determine whether specific traffic is allowed or blocked. Ubuntu comes with a firewall configuration tool called UFW. iptables is an easy-to-use front-end for managing firewall rules. Its main goal is to make firewall management easy or hassle-free as the name suggests. This article explains how to Use UFW tool to configure and manage firewall in Ubuntu 20.04. A properly configured firewall is one of the most important aspects of overall computer security.

UFW is well supported by the Linux community and is installed by default on many distributions. In this article, you will set up A firewall using UFW to protect an Ubuntu or Debian cloud server. You will learn too how to was set up up UFW default rules to allow or deny connections to ports and IP addresses, delete created rules, disable and enable UFW and reset everything to default settings if you want. Below, we have mentioned the setup steps up UFW Firewall in Ubuntu.

6 ways to set up up UFW Firewall in Ubuntu

Set up Up Default policies

  • UFW is installed by default in Ubuntu. If it has been uninstalled for some reason, you can install it with the following command.
  • By default, UFW denies all incoming connections and allows all outgoing connections. It means that the client trying to reach our server cannot connect. When an application from our server tries to connect to any other server outside, it is allowed. The following commands serve the purpose.
    • $ sudo ufw default incoming deny
    • $ sudo ufw allows the default to exit
See also  How to Get macOS Dynamic Wallpaper on Windows 11

Allow SSH connections

  • By default, we have restricted all incoming connections to our server, as seen in our previous step. To allow connections using secure SSH, we will use the following command.
  • The above command will create firewall rules that allow all connections on port 22, which is the default port on which the SSH daemon listens. UFW listens to the port listed in the /etc/services file.
  • If the SSH daemon is configured on a port other than the default, we can specify it in our command to listen on that port. If SSH is configured by us, the following command will query port 2222.
  • We can also specify the protocol (tcp or udp) in our command above. This is optional. The above command is used for both protocols.

Allow specific incoming connections

  • We will use the following commands to specify a rule for UFW to allow incoming connections on a specific port. For example, if we want our server to listen HTTP on port 80, below is the command to execute.
    • $ sudo ufw http allow
    • This is equivalent to the following
    • $ sudo ufw permission 80
  • We can use any of the above for port 80. For HTTPS, either of the following commands will allow the connection.
    • $ sudo ufw https allow
    • Or
    • $ sudo ufw permission 443
  • We can also specify a range of ports, i.e. more than one port. One thing to note is that the protocol must be specified in the command (tcp or udp). The following command allows us to bind ports 6000 to 6003 for both tcp and udp.
    • $ sudo ufw permit 6000:6003/tcp
    • $ sudo ufw permit 6000:6003/udp
See also  How to Keep Windows Laptop On when Lid is Closed

Deny incoming connections

  • Sometimes we want to deny specific connections based on the source IP address. It’s because we know that sometimes our server gets attacked from there. So let’s create a deny rule for a specific IP address. The following command denies connection from IP address 203.0.123.5
    • $ sudo ufw deny from 203.0.123.5

Enables UFW

  • After all the UFW configurations, the next step is to enable it. The following command serves the purpose.
  • After running the above command we will see a warning message. It says that the command may break existing SSH connections. But in this case, we have already set up up A firewall rule that allows SSH connections, so it won’t mess up our configuration. Enter y and press ENTER key to apply. Firewall settings are now applied.

Check the status of UFW

  • We can check the status with the following command.
    • $ sudo ufw status verbose
  • The following is the output at idle.

Final Words

We hope you will understand and enjoy this article up UFW Firewall in Ubuntu. A properly configured firewall is one of the most important aspects of overall computer security. By default, Ubuntu comes with a firewall configuration tool called UFW. UFW is an easy-to-use front-end for managing iptables firewall rules and its main goal is to make iptables management easy or, as the name suggests, hassle-free. If you liked this article, please share it with your family and friends.

Faq

About This Guide?


In this guide, we told you about the How to Set up UFW Firewall on Ubuntu; please read all steps above so that you understand How to Set up UFW Firewall on Ubuntu in case if you need any assistance from us, then contact us.

How this tutorial or guide assisting you?


So in this guide, we discuss the How to Set up UFW Firewall on Ubuntu, which undoubtedly benefits you.



Share this article about How to Set up UFW Firewall on Ubuntu

I hope you like the guide How to Set up UFW Firewall on Ubuntu. In case if you have any queries regards this article/tutorial you may ask us. Also, share your love by sharing this article with your friends and family.
#Set #UFW #Firewall #Ubuntu

See also  How to Hide Drives in Windows 11
Trickbugs: Get the latest Trick and Tips
Logo
Enable registration in settings - general