How to Enable UFW Firewall on Ubuntu
UFW (Uncomplicated Firewall) is the simplest way to filter traffic on Ubuntu. Allow SSH before enabling it or you will lock yourself out.
Steps
Install UFW if needed:
sudo apt updatesudo apt install -y ufwAllow SSH (port 22 or your custom port) before enabling:
sudo ufw allow OpenSSH