Ubuntu Uncomplicated Firewall Setup

Uncomplicated Firewall (ufw) is the default firewall configuration tool on Ubuntu, providing an easy to use wrapper around IPTables which makes dealing with firewall rules a breeze.

For this basic example, we want to allow access to our server on ports 22 (SSH), 80 (HTTP) and 443 (HTTPS).


It is possible to firewall yourself out of your server when changing rules, always make sure you have either physical access to the machine or an alternate point of entry such as a web shell in the case of a VPS.  It will save you a support ticket!
Step 1. Tell ufw to create our allow rules

sudo ufw allow 22
sudo ufw allow 80
sudo ufw allow 443

Step 2. Enable ufw

sudo ufw enable

Now that ufw is up and running, test the ports to ensure you have access.
If you want to view the rules created by ufw, they can be found in


For more in-depth information about ufw configuration check out the Ubuntu server guide documentation.