The Linux kernel includes the netfilter framework that provides packet filtering, NAT, packet logging, and various other features. It can be managed with userspace utilities such as iptables, or its successor nftables.
These are very powerful and flexible utilities though. Beginners are better off using Uncomplicated Firewall (ufw), which is a front-end to these utilities. Ufw is also the default firewall configuration tool on Ubuntu.
Manage Firewall with Ufw
Ubuntu ships with no TCP or UDP ports open. As there are zero open ports, the firewall is also disabled by default. You can check its status with
sudo ufw status
Enable Firewall on Ubuntu
Eventually, you may start using programs and services like Apache or SSH that expose your system to the internet. When using these, it’s important to enable the firewall to ensure that only authorized connections can be established.
sudo ufw enable
Disable Firewall on Ubuntu
Sometimes, you may have difficulty accessing certain web services like a VPS. One way to test if the firewall is causing this is by temporarily disabling it.
sudo ufw disable
Reset Ubuntu Firewall
If you want to configure your firewall rules from scratch, you can get a fresh start by resetting all rules to installed defaults. This will also reset the firewall to
disabled as that’s the default state.
sudo ufw reset
Manage Firewall Graphically (GUFW)
Just as UFW is a CLI front-end to firewall backends like iptables or nftables, GUFW is a graphical front-end to UFW. As the name implies uncomplicated firewall is pretty easy to use and configure. But if you’d prefer to stick to the GUI, GUFW is a good option.
sudo apt install gufw
After installing it, launch it from the Applications menu or directly from the terminal by entering
You can enable or disable the firewall easily with the Status toggle. When enabled, the Ubuntu firewall allows outgoing connections and denies incoming connections as the default behavior. You can obviously change this if you wish.
Aside from the convenient GUI, a major benefit of using GUFW is the fact that it allows you to manage profiles. You can import and export gufw profiles, which makes adding/removing rules or setting up fresh systems quick and easy.