Enable UFW Firewall

Ubuntu: Enable UFW Firewall

UFW (Uncomplicated Firewall) is a simple tool to manage iptables firewall rules. This guide explains how to enable and configure UFW on Ubuntu.


Step 1: Install UFW

sudo apt update

sudo apt install ufw -y


Step 2: Allow SSH Access

sudo ufw allow ssh


Step 3: Allow Web Traffic

sudo ufw allow 80/tcp

sudo ufw allow 443/tcp


Step 4: Enable Firewall

sudo ufw enable


Step 5: Check Status

sudo ufw status verbose


Best Practices

  • Always allow SSH before enabling firewall
  • Restrict unused ports
  • Use ufw deny to block specific traffic