Firewall Configuration and Network Security with UFW
A properly configured firewall is your first line of defense against network-based attacks.
Basic Configuration
# Deny all incoming traffic by default
sudo ufw default deny incoming
# Allow all outgoing traffic by default
sudo ufw default allow outgoing
# Allow SSH connections (CRITICAL!)
sudo ufw allow ssh
# Allow HTTP and HTTPS traffic
sudo ufw allow http
sudo ufw allow https
# Enable the firewall
sudo ufw enable
CopyRate Limiting Connections
To protect against brute-force attacks on SSH, you can rate-limit connections:
sudo ufw limit ssh
Copy