How to Use the CSF Firewall on a CentOS 7 Cloud Server?

29-01-2024 03:21:24

CSF (ConfigServer Security & Firewall) is a stateful packet inspection firewall tool, offering intrusion detection and login protection for Linux cloud servers. Although CSF is a popular security suite, it is not installed by default on CentOS 7. CentOS 7 has moved away from iptables, adopting firewalld as its default firewall. However, some long-time CentOS users find firewalld overly complex and prefer to continue using iptables, which is the underlying firewall for CSF. This guide explains how to disable firewalld, install iptables and CSF, and manage their configurations.

Disabling firewalld:

systemctl disable firewalld
systemctl stop firewalld

Installing iptables:

yum -y install iptables-services

Creating necessary files for iptables:

touch /etc/sysconfig/iptables
touch /etc/sysconfig/iptables6

Enabling iptables:

systemctl start iptables
systemctl start ip6tables
systemctl enable iptables
systemctl enable ip6tables

Installing dependencies for CSF:

yum -y install wget perl unzip net-tools perl-libwww-perl perl-LWP-Protocol-https perl-GDGraph -y

Commencing the installation of CSF:

cd /opt
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh

Removing installation files:

rm -rf /opt/csf
rm /opt/csf.tgz