How To Install Firewalld in Linux Systems

Firewalld is a dynamic firewall management tool that simplifies the process of controlling network traffic in Linux. This guide explains how to install, enable, and configure Firewalld across major Linux distributions.

Debian-Based Distributions

  • Install Firewalld: sudo apt install firewalld
  • Enable and start:
    sudo systemctl enable firewalld
    sudo systemctl start firewalld
  • Check status: sudo systemctl status firewalld

Red Hat-Based Distributions

  • Install Firewalld: sudo dnf install firewalld
  • For older versions: sudo yum install firewalld
  • Enable and start:
    sudo systemctl enable firewalld
    sudo systemctl start firewalld
  • Check status: sudo systemctl status firewalld

Arch-Based Distributions

  • Install Firewalld: sudo pacman -S firewalld
  • Enable and start:
    sudo systemctl enable firewalld
    sudo systemctl start firewalld
  • Check status: sudo systemctl status firewalld

openSUSE-Based Distributions

  • Install Firewalld: sudo zypper install firewalld
  • Enable and start:
    sudo systemctl enable firewalld
    sudo systemctl start firewalld
  • Check status: sudo systemctl status firewalld

Basic Firewalld Configuration Commands

  • Allow SSH (port 22):
    sudo firewall-cmd --zone=public --add-service=ssh --permanent
    sudo firewall-cmd --reload
  • Allow HTTP (port 80):
    sudo firewall-cmd --zone=public --add-service=http --permanent
    sudo firewall-cmd --reload
  • Allow HTTPS (port 443):
    sudo firewall-cmd --zone=public --add-service=https --permanent
    sudo firewall-cmd --reload
  • Allow a specific port (e.g., 8080/tcp):
    sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
    sudo firewall-cmd --reload
  • Deny a specific port (e.g., 8080/tcp):
    sudo firewall-cmd --zone=public --remove-port=8080/tcp --permanent
    sudo firewall-cmd --reload
  • List all active rules: sudo firewall-cmd --list-all
  • Reset all rules:
    sudo firewall-cmd --runtime-to-permanent
    sudo firewall-cmd --reload

Important Notes

  • Firewalld uses zones to manage rules. The default zone is public, but you can use others like home, work, or trusted.
  • Always reload Firewalld after making rule changes.
  • Use --permanent to make rules persist after a restart; otherwise, they apply only to the current session.

By installing and configuring Firewalld, you gain a flexible and powerful way to manage network traffic on your Linux system. Its zone-based approach makes it adaptable to different environments and security needs.

Regularly reviewing your firewall rules ensures your system remains secure, efficient, and protected against unauthorized access.

Post a Comment

Previous Post Next Post

Contact Form