Configure firewall
Description
In this guide, you will learn how to configure a basic firewall using the firewall application UFW (uncomplicated firewall).
We are using the Linux operating system Ubuntu 24.04.
What you’ll learn
Step by step guide
Bash
# Install UFW
apt install ufw -y
# Check firewall status
ufw status
# Set default policies
ufw default deny incoming
ufw default allow outgoing
# Allow SSH connections
ufw allow 22/tcp comment 'SSH'
# Enable the firewall
ufw --force enable
# Check firewall configuration
ufw status verbose
# Reload firewall rules
ufw reload