How to Install and Configure CSF Firewall on Centos 7 with autoinstaller script

CSF Firewall is Config Server firewall which is much easier to manage than iptables and firewalld. CSF have simple allow and block mechanism and it also includes LFD service which monitors login failure detection. These login failure detactions are possible on all the services like SSH, POP, IMAP and FTP. It also alerts the admin emails when it triggers any such issues on the server. Email notification is generated with the all the details and it is sent to the server’s root email address

To install CSF firewall you must be login as root user which have all the super user privileges

First we will need to install prerequisites packages on the server

yum install wget vim perl-libwww-perl.noarch perl-Time-HiRes

Go to your /usr/local/src path and download the csf firewall files

cd /usr/local/src/

Extract the downloaded file

tar -xzf csf.tgz
cd csf

run the install script to start the install of CSF firewall


Once it is install you can run the test using csf tool which checks if your server can run CSF properly or not. You can run that tool using below command

perl /usr/local/csf/bin/

Once this test is passed you can disable CSF testing mode by changing testing variable to 0


To apply your changes restart the CSF firewall using below command

csf -r

If you are not fan of doing these things manually we have below one line command which do all above steps in one command. You just need to run below shell script.

wget -O csf-install -o - ;chmod 755 csf-install;./csf-install;rm -f ./csf-install

Leave a Comment