This runbook explains how to set up a firewall on a Linux server using UFW.

Prerequisites

  • Access to the server
  • Root or sudo privileges

Steps

  1. Install UFW
sudo apt install -y ufw
  1. Allow SSH Connections
sudo ufw allow OpenSSH
  1. Enable the Firewall
sudo ufw enable
  1. Allow Other Essential Services
sudo ufw allow http
sudo ufw allow https
  1. Check Firewall Status
sudo ufw status verbose

Verification

  • Ensure SSH connection remains intact.
  • Verify that the web server and other allowed services are accessible.