How do you use firewall basics (ufw, firewalld) with an example?

Learn the basics of using UFW and Firewalld for firewall management on Linux. Set up and configure firewalls to enhance system security effectively.

Firewall, UFW, Firewalld, Linux, Security, Network Management, System Administration

Firewalls are essential in securing your Linux systems. Below, we discuss two popular firewall management tools, UFW (Uncomplicated Firewall) and Firewalld, along with practical examples of their usage.

Using UFW (Uncomplicated Firewall)

UFW is designed to be an easy way to manage a Netfilter firewall. It is particularly well-suited for host-based firewalls.


# Install UFW (if not already installed)
sudo apt install ufw

# Enable UFW
sudo ufw enable

# Allow SSH connections
sudo ufw allow ssh

# Allow HTTP traffic
sudo ufw allow http

# Check UFW status
sudo ufw status

# Disable UFW
sudo ufw disable
    

Using Firewalld

Firewalld is a dynamic firewall management tool with support for zones that define the trust level of network connections or interfaces.


# Install Firewalld (if not already installed)
sudo yum install firewalld

# Start Firewalld
sudo systemctl start firewalld

# Enable Firewalld to start on boot
sudo systemctl enable firewalld

# Allow SSH service
sudo firewall-cmd --permanent --add-service=ssh

# Allow HTTP service
sudo firewall-cmd --permanent --add-service=http

# Reload Firewalld to apply changes
sudo firewall-cmd --reload

# Check Firewalld status
sudo firewall-cmd --state
    

Firewall UFW Firewalld Linux Security Network Management System Administration