Introduction
Ubuntu comes pre-installed with a firewall configuration tool, UFW (Uncomplicated Firewall). UFW is easy to use for managing server firewall settings.
This tutorial shows you how to disable and enable an Ubuntu UFW firewall using the command line.
Prerequsites
- Command line / terminal window
- User with root or sudo privileges
Check Ubuntu Firewall Status
Before disabling the UFW firewall, it is a good idea to check its status first. In Ubuntu, the firewall is disabled by default. How do you know if your firewall is on?
To check the current status of the firewall, execute the command in your command terminal:
sudo ufw status
In this example below, the output shows that the firewall is active.
As we have determined the current state, now we can proceed to disable the UFW firewall.
Disable Ubuntu Firewall
A firewall is a vital element in a network and server security. However, while testing or troubleshooting, you might need to shut down or stop the firewall.
To disable the firewall on Ubuntu, enter:
sudo ufw disable
The terminal informs you that the service is no longer active.
If you disable the firewall, keep in mind that your firewall rules are still in place. Once you enable the firewall again, the same rules that were set up prior to the deactivation will apply.
Enable Firewall
Learning how to enable the firewall on Ubuntu is vital.
To enable the firewall on Ubuntu, use the command:
sudo ufw enable
As with the ‘disable’ command, the output confirms that the firewall is once again active.
Using UFW to Set Firewall Rules
UFW does not provide complete firewall functionality via its command-line interface. However, it does offer an easy way to add or remove simple rules.
A good example is opening an SSH port.
For example:
sudo ufw allow 22
Once the terminal confirms that the rule is now in place, check the status of the firewall with the ‘status’ command:
sudo ufw status
The output is going to reflect the fact that an SSH port is now open.
Reseting UFW Firewall Rules
If you need to reset all rules back to default settings, use the reset command:
sudo ufw reset
After confirming the action, by typing y
, the firewall settings revert to their default values.
Conclusion
In this guide, you learned how to disable and stop the firewall on Ubuntu. We also showed you how to enable the firewall and reset settings.
Now you know the options available with the UFW tool. These commands provide an excellent foundation to explore firewall functions and settings.
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/224066.html