OS: Debian 11 (Bullseye)

In this tutorial I will show you how to quickly install ufw in Debian 11. Do take note that if you do not specific the protocol by default both TCP and UDP protocol will be enabled

Install ufw in Debian.

sudo apt install ufw

  1. First lets allow ssh connection

sudo ufw allow 22

  1. Next configure default connection for incoming and outgoing.

sudo ufw default deny incoming
sudo ufw default allow outgoing

  1. Enable ufw logging

sudo ufw logging on

  1. Enabling ufw firewall

sudo ufw enable

  1. Show added ufw allowed ports

sudo ufw show added

  1. Show the current configurations.

sudo ufw status verbose

For those of you who are configuring vpn server you might want to enable the following UDP ports for IP Sec.

sudo ufw allow 500/udp
sudo ufw allow 4500/udp

To allow the default port for vnc.

sudo ufw allow 5901/tcp