In most cases, a firewall is used for port forwarding, allowing a system to share the required data with all users. A firewall is used for inbound and outbound port forwarding. It can route traffic to TCP and UDP ports.

In this tutorial, I can guide you on how to turn on and off the firewall on Ubuntu. In my case, I am using the latest Ubuntu 23.10 operating system. You can use any Ubuntu version for the Firewall Service. A firewall is used to route access over the Internet. It's used in web applications, websites, web servers, and more remote services access.

In the Ubuntu operating system, "ufw" is available by default for managing user connections. When you set up a remote host or other service, you can enable HTTP, HTTPS, RDP, or other ports for remote access.

Turn on and off Firewall in Ubuntu

By default, the ufw firewall is enabled on the Ubuntu operating system, but no ports are forwarded over the firewall. You can also check the firewall status with the given command:

$ sudo systemctl status ufw
root@server:~# sudo systemctl status ufw
 ufw.service - Uncomplicated firewall
     Loaded: loaded (/lib/systemd/system/ufw.service; enabled; preset: enabled)
     Active: active (exited) since Thu 2024-01-25 12:50:39 UTC; 1min 3s ago
       Docs: man:ufw(8)
   Main PID: 402 (code=exited, status=0/SUCCESS)
        CPU: 1ms

Jan 25 12:50:39 ubuntu systemd[1]: Starting ufw.service - Uncomplicated firewal>
Jan 25 12:50:39 ubuntu systemd[1]: Finished ufw.service - Uncomplicated firewal>
root@server:~# 

From the given output, you can see that my ufw service is active. Then, when I create any role in network routing, it's applied and live immediately. Press "q" to exit from the dashboard. If your firewall service is inactive and you need to activate it, then put the given commands to turn on the firewall:

$ sudo systemctl start ufw

$ sudo systemctl enable ufw

From the given output section, you can see that the firewall service is active. For some error or technical issue that makes your site under maintenance, you need to close the web access temporarily and disable public access to stop the firewall with the given command on Ubuntu:

$ sudo systemctl stop ufw

$ sudo systemctl disable ufw

root@server:~# sudo systemctl stop ufw
root@server:~# sudo systemctl disable ufw
Synchronizing state of ufw.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable ufw
Removed "/etc/systemd/system/multi-user.target.wants/ufw.service".
root@server:~# sudo systemctl status ufw
○ ufw.service - Uncomplicated firewall
     Loaded: loaded (/lib/systemd/system/ufw.service; disabled; preset: enabled)
     Active: inactive (dead)
       Docs: man:ufw(8)
root@server:~# 

When you disable this access, it's okay. Access over your local device does not mean you can access the site or web application over a private device.

If you like this content and you need to read more of this type of content, then subscribe to my blog.

The link has been copied!