How to Enable or Disable UFW Firewall on Ubuntu ?

Enable or disable UFW Firewall on Ubuntu, UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables firewall rules in Ubuntu and other Linux distributions. It simplifies the process of setting up a firewall to control network traffic, allowing users to configure which services can be accessed and from where.

By enabling UFW, you add a layer of security to your server by blocking unwanted or malicious connections, while still allowing access to essential services like SSH, HTTP, and HTTPS. Disabling UFW, on the other hand, stops the firewall, which may be necessary in some troubleshooting scenarios

1. Check UFW Status to Enable or Disable UFW Firewall on Ubuntu

Before enabling or disabling UFW, it’s good to check if it’s currently active.

   sudo ufw status
  • Active: UFW is enabled and running.
  • Inactive: UFW is disabled.

2. Enable UFW

To enable the firewall and start blocking or allowing rules:

   sudo ufw enable

You will get a confirmation that UFW is enabled. It will start enforcing any configured rules.

3. Disable UFW

Enable or Disable UFW Firewall on Ubuntu

To turn off the firewall:

   sudo ufw disable

UFW will stop, and it will no longer enforce any firewall rules.

4. Allow Specific Ports (Optional)

When enabling the firewall, ensure you allow necessary ports. For example, to allow SSH (port 22):

   sudo ufw allow ssh

You can also allow other services by specifying their port numbers:

   sudo ufw allow 80    # Allow HTTP
   sudo ufw allow 443   # Allow HTTPS

5. Reload UFW Rules (Optional)

After making changes, you can reload the firewall rules:

   sudo ufw reload

This is how you can Enable or Disable UFW Firewall on Ubuntu and manage basic firewall settings on Ubuntu.

By Ashwath