Basic Usage example of Linux Firewalld UFW
What is Firewalld?
Firewalld is a dynamic firewall management tool included in many Linux distributions such as RHEL, CentOS, and Fedora. It offers a user-friendly interface for managing firewall rules and network zones.
Firewalld supports two types of configuration:
- Permanent: Rules that persist across system reboots.
- Runtime: Temporary rules that are lost when the system or service restarts.
Firewalld organizes network traffic into zones, enabling different sets of rules for various networks—such as public, internal, or trusted.
Firewalld’s configuration is stored in two directories:
- /usr/lib/firewalld: Contains default configurations that may be overwritten by system updates.
- /etc/firewalld: Holds system-specific configurations that persist across reboots and updates.
Managing Firewalld Service in RHEL Systems
Start Firewalld:
systemctl start firewalld
Stop Firewalld:
systemctl stop firewalld
Check Firewalld Status:
systemctl status firewalld
Check Firewalld State:
firewall-cmd --state
Enable Firewalld at Boot:
systemctl enable firewalld
Disable Firewalld:
systemctl disable firewalld
Mask Firewalld (Prevent Starting):
systemctl mask firewalld
Unmask Firewalld:
systemctl unmask firewalld
What is UFW?
UFW (Uncomplicated Firewall) is the default firewall management tool for Ubuntu and some other Linux distributions.
UFW is a user-friendly frontend for managing firewall rules with iptables. It simplifies firewall management for users who don’t need the full complexity of iptables.
Managing UFW Service in Debian Systems
Here are some common commands to manage UFW on Debian-based distributions
Enable UFW:
sudo ufw enable
Disable UFW:
sudo ufw disable
Check UFW Status:
sudo ufw status
Adding and Managing Rules with UFW
Here are the basic commands to manage UFW:
Allow a Specific Port (e.g., HTTP port 80):
sudo ufw allow 80
Deny a Specific Port:
sudo ufw deny 80
Allow SSH Traffic:
sudo ufw allow ssh
Delete a Rule:
sudo ufw delete allow 80
Enable Logging:
sudo ufw logging on
https://www.tecmint.com/manage-firewalld-and-ufw-on-linux/