CSF Firewall installation and configuration

ConfigServer Firewall (CSF) is an advanced firewall suite for Linux systems that enhances the security on your Server. It also has the Login Failure Daemon (LFD) process that regularly scans for failed login attempts on your Server and takes action against the offending IP Addresses.

Note

This documentation assumes that you are connected to the Server using an SSH client as a root user.

To Install CSF on a Server

Change the present working directory to /usr/local/src using the command below. You may choose any other directory of your choice, where you want the installation script to be downloaded.

cd /usr/local/src

Run the below command to download the archive file to the present working directory:

wget http://configserver.com/free/csf.tgz

Extract the files using the command:

tar xfz csf.tgz

Go to the CSF directory using the command:

cd csf

To install CSF:

On a Server Without any Hosting Panel

Run the general installation script ./install.generic.sh.

On a Server With cPanel or DirectAdmin

Run the installation script ./install.cpanel.sh to install CSF on a Server with cPanel.

Run the installation script ./install.directadmin.sh to install CSF on a Server with DirectAdmin.

The CSF Firewall will be installed in the /etc/csf directory and the allowed inbound/outbound port configuration will be adjusted as per the current settings. You can make further adjustments through the configuration file /etc/csf/csf.conf.

Restart the firewall for the changes to take effect using the command:

/etc/init.d/csf restart

You can disable the testing flag by changing the value for TESTING from 1 to 0 in the configuration file /etc/csf/csf.conf using an editor like vi.

Note

Ensure that all your custom firewall settings are working perfectly before you disable the testing mode.

Restart the Firewall again.

To Manage CSF

CSF can be managed through the Command Line Interface. The command csf would present a list of commands and the information related to them.

A few basic commands are:

Allowing an IP Address

csf -a <ip_address>

Denying an IP Address

csf -d <ip_address>

You can manage the CSF settings from your WHM Panel (Home >> Plugins).