Like many Linux distributions, Windows, and macOS, Ubuntu has a firewall. This security feature can prevent connections from unwanted sources on your system. Sometimes, though, you might want to disable it (or at least configure the firewall with port-forwarding rules) if you want to let network traffic through. Ubuntu's default firewall configuration tool is known as iptables and can be managed through Uncomplicated Firewall, better known as UFW. Usually, iptables is off by default, but you can configure it easily with the terminal.

What is the Ubuntu Firewall?

Ubuntu's firewall is disabled by default, but it can be activated in a matter of moments. UFW is an interface of iptables, the underlying Linux firewall. iptables can be relatively difficult to configure correctly, especially as a newcomer to Ubuntu. A firewall will allow your Ubuntu installation to filter traffic, blocking any unwanted connections. UFW is a great way to enable additional protections for your network connections. Supporting IPv4 and IPv6, there's also a GUI version of UFW called GUFW.

How to disable the Ubuntu Firewall

Disabling the Ubuntu Firewall is an easy task that can almost be replicated to enable it. Here's how to do it:

  1. Open Terminal.
  2. Check if the firewall is active:
    sudo ufw status
    A screenshot of the command in the Ubuntu terminal to see the firewall status
  3. If active, disable the firewall:
    sudo ufw disable
    A screenshot of the command in the Ubuntu terminal to disable the firewall

It's also possible to add or remove rules for the firewall using similar commands. If you want to open an SSH port on port 22, use the command sudo ufw allow 22. If you're having issues, reset the firewall to its default state with sudo ufw reset. Ubuntu's firewall is a basic yet powerful means to protect your system against outside threats.

How to enable the Ubuntu firewall

Want to turn the protection back on for your Ubuntu installation? Here's how to do it:

  1. Open Terminal.
  2. Check if the firewall is inactive:
    sudo ufw status
  3. Enable the firewall:
    sudo ufw enable
    Enabling Ubuntu firewall

The Ubuntu firewall will now be active and protecting your PC from connections not allowed by the configured rules.

Do you need the Ubuntu firewall?

No, the average user does not require the firewall to be active unless running services on the system. Should you fire up something that can handle outside connections, such as a web server, you will require a firewall to be active to improve security. For everyone else, the default Ubuntu configuration (i.e. disabled) is just fine. The reason is your router has a built-in firewall that should be able to handle incoming traffic.

As you can tell, there's not much to enable or disable the firewall on Ubuntu. It's one of the more basic things you can do in the open-source operating system. This guide showed the basics of turning it on and off, resetting it, and even using it to enable a port.