The tool is user-friendly and allows system admins to manage the Ubuntu firewall module. You can use UFW to enable and manage firewall rules as well as disable it if it’s already enabled. This brief tutorial shows students and new users how to enable and manage Ubuntu firewalls on Ubuntu 16.04 | 18.04 servers and create rules that will keep your server secured and protected from external threats. When you’re ready to manage the Ubuntu firewall, follow the steps below:

Enable Ubuntu Firewall

Since the firewall module is disabled by default, the commands below enable it. But first, run the commands below to see the status of the firewall system. That should display a similar message as below: Status: inactive This is the default state of the firewall module. You can also run the commands below to check the status Now. to protect your server, you’ll want to enable the firewall module. If the firewall is activated, by default, it will block all incoming connections and allow all outbound connections. So if you’re running servers and services that must be assessed externally, you’ll want to allow those traffic. The good thing about Ubuntu is many of the popular servers and services have profiles that can be managed via UFW to allow and disallow traffic to them. The apt command adds an application profile to the/etc/ufw/applications.d directory. You can list these profiles by running the commands below: You should see a list of apps that can easily be allowed and disallowed via UFW. Now you can easily run the commands below to allow external traffic to the Nginx HTTP server. To allow SSH run the commands below: You can also use the service name instead of the app profile to enable or disable it. For example, if you  wish to enable HTTP over port 80, run the commands below: Or HTTPS, run the commands below: The same can also be accomplished using the commands below to allow HTTP over TCP on port 80 or HTTPS over TCP on port 443 You can do that for all the apps you want to allow traffic to. After you’ve updated the firewall rules, you can finally enable UFW. To allow specific computers via IP address 192.168.1.2, run the commands below: To deny the same IP, run the commands below: That should enable the firewall and the rules you created above.

Disable Ubuntu Firewall

If you want to disable the Ubuntu firewall, you can run the commands below to disable it. The command above will stop and disable the firewall but it will not delete the firewall rules. The next time you enable a firewall, it should automatically reapply those rules you enabled previously. To disable and delete all the rules, simply run the commands below: You’ll be prompted to continue with the change. Type Y to accept and continue. That should do it. More rules could be added to Ubuntu firewall configurations. but the few above should get you started. You may also like the post below: