Setting up UFW
UFW stands for uncomplicated firewall. So basically, UFW is a simple and efficient firewall to your Linux.
Install UFW to Debian
sudo apt install ufw
Install UFW to Arch Linux
sudo pacman -S ufw
Setup the default policies
sudo ufw default deny incoming
sudo ufw default allow outgoing
Allow SSH
sudo ufw allow ssh
or
sudo ufw allow 22
It’s really important to allow SSH, because in the worst case, you log yourself out and you can’t login again, because the incoming traffic is blocked.
Enable UFW
sudo ufw enable
or
sudo systemctl start ufw
sudo systemctl enable ufw
Source(s):