Installing ConfigServer Firewall (CSF)

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

  1. 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

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

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

  3. Extract the files using the command:

    tar xfz csf.tgz

  4. Go to the CSF directory using the command:

    cd csf

  5. 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.

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

    /etc/init.d/csf restart

  7. 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.

    Disabling Testing Mode

  8. 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.

CSF Commands

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).

Managing CSF through WHM