UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables rules on Ubuntu. It ships pre-installed and simplifies tasks that would otherwise require writing complex iptables commands by hand. UFW is the standard way to control inbound and outbound traffic on Ubuntu servers.
Keeping the firewall enabled is strongly recommended for any server exposed to the internet. That said, there are legitimate reasons to disable it temporarily — troubleshooting a connectivity issue, testing network behavior without firewall interference, or migrating to a different firewall solution.
This guide shows you how to disable the firewall on Ubuntu 18.04, how to reset all rules when you want to start fresh, and how to safely re-enable it when you are done.
<strong>Prerequisite:</strong> You need sudo access.
Before making any changes, check the current state of the firewall:
bashsudo ufw status
If UFW has never been activated, the output is:
Status: inactive
If UFW is running, you see:
Status: active
An active status also lists all the rules currently in effect, including which ports are allowed and from which sources.
Disable UFW. To stop the firewall and prevent it from starting at boot, run:
bashsudo ufw disable
The output confirms:
Firewall stopped and disabled on system startup
This is an important distinction: ufw disable stops the firewall and removes it from the startup sequence, but it does not delete any of your rules. All your existing allow and deny rules are preserved in the configuration files. The next time you run sudo ufw enable, those same rules load automatically without any extra setup.
Use ufw disable when you need the firewall off temporarily and plan to turn it back on later.
ufw reset is different from ufw disable. It does not just stop the firewall — it deletes all of your custom rules and reverts UFW to its default state. This is the right command when you want to wipe your firewall configuration and start over from scratch.
Run:
bashsudo ufw reset
UFW asks you to confirm before proceeding:
Resetting all rules to installed defaults. This may disrupt existing sshconnections. Proceed with operation (y|n)?
After you type y, UFW backs up your existing rule files before deleting them. The backup filenames include a timestamp, for example:
Backing up 'user.rules' to '/etc/ufw/user.rules.20190122_115214'
These backups are stored in /etc/ufw/ and can be restored manually if you change your mind. After a reset, UFW is disabled and all previously configured ports are closed.
Note: After a reset, do not run
ufw enablebefore adding an allow rule for SSH (port 22). Enabling the firewall without an SSH rule will lock you out of a remote server immediately.
When you are ready to turn the firewall back on, make sure SSH access is allowed first. If your SSH rule was wiped by a reset, add it back before enabling:
bashsudo ufw allow OpenSSH
Then enable the firewall:
bashsudo ufw enable
UFW asks for confirmation because enabling it can interrupt existing SSH sessions:
Command may disrupt existing ssh connections. Proceed with operation (y|n)?
Type y and the firewall activates:
Firewall is active and enabled on system startup
Run sudo ufw status to confirm the firewall is running and to review the active rules. If you used ufw disable earlier (not ufw reset), your original rules are already loaded and no further setup is needed.
The UFW firewall is now under your control on Ubuntu 18.04. For a full guide on setting up rules, managing ports, and configuring allowed IP ranges, read the UFW setup guide for Ubuntu 18.04. Leave a comment below if you run into any issues.
VirtualBox is a free, open-source, cross-platform virtualization application maintained by Oracle. It lets you run multiple…
PostgreSQL (also called Postgres) is a free, open-source, object-relational database management system with a strong reputation…
VMware Workstation Player is a mature, stable virtualization platform that lets you run multiple isolated operating…
A properly configured firewall is one of the most important layers of security for any internet-facing server. UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables rules that ships pre-installed on Ubuntu. Its defaults are sensible: block all incoming connections, allow all outgoing connections. No outside traffic reaches your server unless you explicitly open a port. This guide covers how to configure a UFW firewall on Ubuntu 18.04, from setting default policies and application profiles to writing allow and deny rules for specific ports, IPs, and subnets. <strong>Prerequisite:</strong> You need sudo access. Configure UFW Firewall on Ubuntu: Defaults, SSH, and Application Profiles If UFW is not installed, add it with: bashsudo…
Apache Cassandra is a free, open-source NoSQL database designed for high availability and linear scalability with…
Rocket.Chat is a free, open-source team communication platform built with the Meteor framework. It is a…