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
1
# Install UFW2
apt install ufw -y3
4
# Check firewall status5
ufw status6
7
# Set default policies8
ufw default deny incoming9
ufw default allow outgoing10
11
# Allow SSH connections12
ufw allow 22/tcp comment 'SSH'13
14
# Enable the firewall15
ufw --force enable16
17
# Check firewall configuration18
ufw status verbose19
20
# Reload firewall rules21
ufw reload