🛡 How to Configure UFW on Linux VPS
UFW (Uncomplicated Firewall) is a user-friendly tool for managing a firewall on Linux. It's perfect for basic VPS protection and is beginner-friendly. In this guide, we'll show how to enable, configure, and use UFW on Ubuntu/Debian servers.
🔧 Installing and Enabling UFW
- Install UFW (if not already installed):
sudo apt install ufw
- Check UFW status:
sudo ufw status
- Allow SSH before enabling:
sudo ufw allow ssh
orsudo ufw allow 22
- Enable UFW:
sudo ufw enable
📌 Basic UFW Commands
- Allow a port:
sudo ufw allow 80
(HTTP),sudo ufw allow 443
(HTTPS) - Deny a port:
sudo ufw deny 21
- Remove a rule:
sudo ufw delete allow 80
- View current rules:
sudo ufw status numbered
- Disable UFW:
sudo ufw disable
🚨 Security Tips
- 🔐 Do not block port 22 or you’ll lose SSH access.
- 📋 Only allow necessary ports: 80/443 for websites, 3306 for MySQL (if needed).
- 🧪 Test your site and services after enabling the firewall.
If you need help configuring your firewall, contact Bit.Hosting support and we’ll assist you.