Securing your Linux system is essential, and UFW (Uncomplicated Firewall) provides a simple way to manage firewall rules. This guide explains how to install, enable, and configure UFW across major Linux distributions.
Debian-Based Distributions
- Install UFW:
sudo apt install ufw - Enable UFW:
sudo ufw enable - Alternatively, enable and start via systemd:
sudo systemctl enable ufwsudo systemctl start ufw - Check status:
sudo ufw status
Red Hat-Based Distributions
- Install UFW:
sudo dnf install ufw - Enable and start via systemd:
sudo systemctl enable ufwsudo systemctl start ufw - Check status:
sudo ufw status
Arch-Based Distributions
- Install UFW:
sudo pacman -S ufw - Enable and start via systemd:
sudo systemctl enable ufwsudo systemctl start ufw - Check status:
sudo ufw status
openSUSE-Based Distributions
- Install UFW:
sudo zypper install ufw - Enable and start via systemd:
sudo systemctl enable ufwsudo systemctl start ufw - Check status:
sudo ufw status
Basic UFW Configuration Commands
- Allow SSH (port 22):
sudo ufw allow sshorsudo ufw allow 22/tcp - Allow HTTP (port 80):
sudo ufw allow httporsudo ufw allow 80/tcp - Allow HTTPS (port 443):
sudo ufw allow httpsorsudo ufw allow 443/tcp - Deny incoming traffic:
sudo ufw deny <port>/tcp - Delete a rule:
sudo ufw delete allow <port>/tcp - Reset all rules:
sudo ufw reset
Important Notes
- Always allow SSH before enabling UFW if managing a remote server.
- Default policy: deny incoming, allow outgoing connections.
- Use
sudo ufw status verbosefor detailed rule information. - Use
sudo ufw status numberedwhen deleting rules by number.
By installing and configuring UFW, you add an essential layer of security to your Linux system. Its simplicity makes firewall management accessible while ensuring strong protection.
Regularly reviewing and updating your UFW rules helps maintain a secure environment and keeps your system resilient against unauthorized access.
Tags
Linux
%20in%20Linux%20Systems.webp)