Security

Secure Ubuntu 22.04 with UFW Firewall

Harden your Ubuntu 22.04 server security by configuring UFW (Uncomplicated Firewall).

December 20, 2025 933 views

Hardening Ubuntu 22.04 with UFW Firewall

Secure your Ubuntu 22.04 server by implementing UFW Firewall. This guide covers essential security measures to protect your VPS.

Why Security Matters

UFW provides a simple interface for managing iptables firewall rules, essential for protecting your server from unauthorized access.

Step 1: Install UFW Firewall

sudo apt update
sudo apt install ufw -y

Step 2: Configure Firewall Rules

Set up basic firewall rules:

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

Step 3: Enable UFW Firewall

sudo ufw enable

Step 4: Verify Configuration

sudo ufw status verbose

Additional Security Tips

  • Always allow SSH before enabling UFW to avoid being locked out
  • Use specific port numbers instead of service names for better control
  • Regularly review firewall logs at /var/log/ufw.log

Conclusion

Your Ubuntu server is now protected with UFW Firewall. Regular security audits are recommended.


Search Docs
Security

Security best practices, hardening guides, and firewall configurations

View all articles