Introduction
Ubuntu comes pre-installed with a firewall configuration tool, Uncomplicated Firewall(UFW). UFW is easy to use and allows you to manage server firewall settings.
This tutorial shows you how to disable or enable a Ubuntu UFW firewall and how to check its status.
Prerequisites
- A machine running Ubuntu (this tutorial uses Ubuntu 22.04).
- Access to the terminal.
- User with root or sudo privileges.
How to Check Ubuntu Firewall Status
Check the Ubuntu firewall status before turning it on or off to understand your system's current security settings. Additionally, this action avoids disrupting existing network configurations.
To check the status of the firewall, enter:
sudo ufw status
The output shows the firewall is active.
How to Disable Ubuntu Firewall
A firewall is vital to network and server security. However, you might need to stop it while testing or troubleshooting. The following text explains how to stop the UFW service, disable it at boot, and uninstall it.
Stop UFW Service
To stop UFW service, run the following command:
sudo systemctl stop ufw
The command does not produce an output but stops the UFW service immediately. This command does not affect whether it starts again at the next boot.
Disable UFW at Boot
There are two methods for disabling UFW at boot. They are similar but serve slightly different purposes.
One way to disable UFW at boot is with the following command:
sudo ufw disable
This command stops UFW immediately and resets its status to inactive, meaning it does not filter traffic until re-enabled. The service is not automatically re-enabled at the next boot.
Another way to disable UFW at boot is with the following command:
sudo systemctl disable ufw
The command prevents the UFW service from starting automatically at boot time. UFW does not start when the system boots, regardless of whether it was enabled or disabled before.
Uninstall UFW
To completely remove UFW from your system, run the following command:
sudo apt remove ufw
How to Enable Ubuntu Firewall
Knowing how to enable a firewall is crucial for maintaining system security, preventing unauthorized access, and effectively managing network traffic.
To enable the firewall on Ubuntu, use the command:
sudo ufw enable
The output confirms the firewall is once again active.
Conclusion
This tutorial explained how to enable or disable the firewall on Ubuntu. It also elaborated on how to check the UFW status.
Next, learn about different firewall types.