A quick and easy firewall is included with Ubuntu Server – it is easy to set up.
Before doing any work on your Ubuntu Server, it is good practice to update your software repositories using:
Before you start making changes to the firewall, it is a good idea to check its status:
You can also list any running applications that have registered a profile with the firewall:
ufw app list
If you access your server via SSH then you need to allow that service before you enable the firewall:
ufw allow OpenSSH
If you are enbling a profile that has spaces in the name, simply wrap your service name in quotes:
ufw allow 'Apache Full'
Once you’re sure you’re happy with the firewall setup, enable your firewall:
You can now see what profiles are active by running: