CentOS, a popular distribution among Linux operating systems, plays a crucial role in protecting your system from external threats through firewall configuration. In this guide, we will walk through how to configure the firewall step by step with the "firewall linux centos" keyword.
A firewall is a security system that controls the flow of data in computer networks. A firewall blocks unauthorized access while allowing network traffic based on specific rules. In operating systems like CentOS, a firewall is a critical component to ensure system security.
The importance of firewalls lies in their ability to protect against malicious attacks. Especially as the number of threats from the internet increases, firewalls create a vital defense layer to safeguard our systems.
CentOS comes with a firewall management tool called FirewallD by default. FirewallD stands out with its ability to create and manage dynamic rules.
sudo yum install firewalld
sudo systemctl start firewalld sudo systemctl enable firewalld
sudo systemctl status firewalld
FirewallD provides a powerful structure for controlling services and ports.
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload
FirewallD offers advanced settings such as zones and rich rules to create different security levels.
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.100" accept'
After firewall rules are created, logging becomes important for monitoring and evaluating system security.
sudo journalctl -xe --no-pager -u firewalld
Yes, iptables can also be used on CentOS. However, FirewallD offers a newer and more dynamic structure.
To make changes take effect, you need to run the firewall-cmd --reload command.
You can increase the logging level for more detailed information. This can be done by modifying the LogDenied setting in the /etc/firewalld/firewalld.conf file.