Home > Package & System Management > ufw-enable

ufw-enable: Enable UFW Firewall

ufw-enable is a conceptual command to enable the Uncomplicated Firewall (UFW). In practice, you use the 'ufw enable' command to turn on the system's firewall and configure it to start automatically on system boot. This is a crucial step in enhancing system security.

Overview

UFW is a tool that helps manage firewalls easily on Linux systems. The 'ufw enable' command activates the UFW firewall and ensures that firewall rules are maintained even after system reboots. It's important to verify that appropriate firewall rules are in place before executing this command.

Key Features

  • Enables the UFW firewall
  • Configures automatic startup on system boot
  • Applies default policies (deny incoming, allow outgoing)

Installation

UFW may not be included by default in many Linux distributions, or it might be installed but not enabled. Here's how to install UFW on major distributions.

Debian/Ubuntu

sudo apt update
sudo apt install ufw

Install UFW using the APT package manager.

CentOS/RHEL (EPEL repository required)

sudo yum install epel-release
sudo yum install ufw

Install UFW using the YUM or DNF package manager. You may need to enable the EPEL repository first.

Usage Examples

Demonstrates various ways to enable the UFW firewall.

Enable UFW Firewall

sudo ufw enable

Enables the UFW firewall and configures it to start automatically on system reboots. Executing this command applies the firewall with the currently set rules.

Force Enable Without Confirmation Prompt

sudo ufw --force enable

Immediately enables UFW without the confirmation prompt that appears during activation. Use this option with caution.

Tips & Precautions

Important considerations before and after enabling the UFW firewall.

Check Rules Before Enabling

Before enabling the firewall, check the currently configured rules to ensure that necessary services (e.g., SSH) are not blocked. Otherwise, you might lose access to your system.

  • Check current rules with 'ufw status verbose'
  • Allow necessary ports with 'ufw allow [port/service]'

Caution with Remote Access

If you are enabling UFW while connected to the server remotely, you might lose your connection if the SSH port (default 22) is not allowed. You must allow the SSH port first before enabling the firewall.

Default Policies

Default policies applied when UFW is enabled.

  • Incoming: Deny all connections by default
  • Outgoing: Allow all connections by default

Same category commands