This guide is for learning. Run these commands only on your own lab or servers.
UFW is a simple front end for the Linux firewall. The idea is to deny all incoming traffic and then allow only the services you actually run.
1. Set the defaults
sudo ufw default deny incoming
sudo ufw default allow outgoing2. Allow your services
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp3. Enable and check
sudo ufw enable
sudo ufw status verbose4. Remove a rule
sudo ufw status numbered
sudo ufw delete 3Allow SSH before you enable UFW, otherwise you can lock yourself out of a remote server.
Want every command on one page? Linux & Enterprise Configuration Guide · $9.99View on Gumroad



