Dec 22, 2023 3 min read

How to Enable/Disable Firewall on Ubuntu 20.04

Enable/Disable Firewall on Ubuntu 20.04 with our step-by-step tutorial. It is a vital network security device that acts as a protective barrier.

Enable/Disable Firewall on Ubuntu 20.04
Enable/Disable Firewall on Ubuntu 20.04
Table of Contents

Introduction

Before we begin talking about how to enable/disable Firewall on Ubuntu 20.04, let’s briefly understand – What is Firewall?

A firewall is a vital network security device that acts as a protective barrier. It monitors and filters data traffic, allowing safe connections while blocking unauthorized access and malicious activities. With a firewall, you can ensure the security and integrity of your network, defending against cyber threats effectively.

Acting as a virtual wall, it monitors incoming and outgoing traffic, filtering and analyzing data packets to allow safe connections and block suspicious or malicious activities. By controlling access to your network, a firewall ensures the confidentiality, integrity, and availability of your data while keeping hackers and threats at bay.

In this tutorial, you will enable/disable Firewall in an independent environment on Ubuntu 20.04. We will also address a few FAQs on how to enable/disable Firewall on Ubuntu 20.04.

Advantages of Firewall

  1. Security: Firewalls protect against cyber threats and unauthorized access, ensuring the safety of your network and data.
  2. Control: They give you control over incoming and outgoing traffic, allowing you to block or allow specific connections.
  3. Privacy: Firewalls safeguard your privacy by preventing unauthorized users from accessing your network.
  4. Filtering: They filter out malicious content, stopping viruses, malware, and other harmful elements from entering your network.
  5. Monitoring: Firewalls monitor network traffic, providing insights into potential security breaches and helping you respond promptly.

Software Requirements and Conventions Used

Category Requirements, Conventions or Software Version Used
System Installed or updated Ubuntu 20.04 Focal Fossa
Software ufw (uncomplicated firewall)
Other privileged access with the sudo command or as root to your Linux system.
Conventions # – requires the use of the sudo command or running the given linux commands as the root user with root privileges; $ – required that the given Linux commands be run as a regular, non-privileged user.

Steps to enable/disable firewall on Ubuntu 20.04

Firstly, check the firewall's status to see if it is on or off should be our initial action.

sudo ufw status
Status: active

Our firewall is currently active (on), as may be seen here. Add the verbose option to get more information about your current firewall settings.

sudo ufw status verbose

After that, use the next command to disable the Ubuntu firewall.

sudo ufw disable

You can use the following command if you decide you need to re-enable the Ubuntu firewall in the future.

sudo ufw enable
Warning: Please be aware that if you are currently using SSH to remotely log in to your Ubuntu server, turning on your firewall may cause you to lose connection.

Enable or Disable Ubuntu firewall using GUI

You must use the following command to install the gufw package in order to control ufw using a GUI.

sudo apt install gufw

Launch the gufw programme after that, and select the Status option to enable or disable the firewall. For extra assistance, view the video below.

FAQs to Enable/Disable Firewall on Ubuntu 20.04

How can I check if the firewall is enabled or disabled?

Type sudo ufw status in the terminal. It will display the status of the firewall, whether it is active or inactive.

Can I selectively enable or disable certain ports or services?

Yes, you can. Use commands like sudo ufw allow [port] or sudo ufw deny [port] to customize firewall rules for specific services or ports.

Will enabling the firewall disrupt my internet connection or other applications?

No, enabling the firewall shouldn't disrupt your internet connection or other applications. It only filters network traffic based on predefined rules.

Can I configure the firewall to allow specific IP addresses or ranges?

Absolutely. You can use commands such as sudo ufw allow from [IP address] or sudo ufw allow from [IP range] to allow specific IP addresses or ranges.

How can I block an IP address from accessing my Ubuntu system?

Use the command sudo ufw deny from [IP address] to block a specific IP address from accessing your system.

Does Ubuntu 20.04 come with a pre-installed firewall?

Yes, Ubuntu 20.04 comes with a pre-installed firewall called UFW (Uncomplicated Firewall). However, it may not be enabled by default.

Do I need to restart my system after enabling or disabling the firewall with UFW?

No, you don't need to restart your system after enabling or disabling the firewall using UFW. Changes take effect immediately.

Conclusion

You learnt how to activate or deactivate Ubuntu 20.04's system firewall (ufw) in this tutorial. Also, you learned how to view the firewall's current state. The firewall won't typically need to be disabled unless you want to test something or something similar.

If you have any suggestions or queries, kindly leave them in the comments section.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.