Enable UFW Firewall

Debian: 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 Debian servers.


Step 1: Install UFW

sudo apt update

sudo apt install ufw -y


Step 2: Allow SSH Access

sudo ufw allow ssh

This ensures you don’t get locked out of your server when enabling the firewall.


Step 3: Allow Web Traffic

sudo ufw allow 80/tcp

sudo ufw allow 443/tcp

These commands allow HTTP and HTTPS traffic.


Step 4: Enable Firewall

sudo ufw enable

This activates the firewall with the rules you’ve set.


Step 5: Check Status

sudo ufw status verbose

Displays active rules and firewall status.


Step 6: Deny Unwanted Ports

sudo ufw deny 23/tcp

Blocks Telnet (port 23), which is insecure and should not be used.


Best Practices

  • Always allow SSH before enabling the firewall
  • Restrict unused ports to reduce attack surface
  • Use ufw delete to remove unwanted rules
  • Regularly review firewall rules for accuracy

Note: HostPalace Debian servers support UFW for easy firewall management, helping clients secure their infrastructure quickly.