How To Install Uncomplicated Firewall (UFW) in Linux Systems

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 ufw
    sudo 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 ufw
    sudo 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 ufw
    sudo 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 ufw
    sudo systemctl start ufw
  • Check status: sudo ufw status

Basic UFW Configuration Commands

  • Allow SSH (port 22): sudo ufw allow ssh or sudo ufw allow 22/tcp
  • Allow HTTP (port 80): sudo ufw allow http or sudo ufw allow 80/tcp
  • Allow HTTPS (port 443): sudo ufw allow https or sudo 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 verbose for detailed rule information.
  • Use sudo ufw status numbered when 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.

Post a Comment

Previous Post Next Post

Contact Form