ConfigServer Firewall (CSF)

Install, configure, or uninstall CSF and LFD for your server.

Step-by-Step Instructions

Copyright Notice

###############################################################################
# Copyright (C) 2006-2025 Jonathan Michaelson
#
# https://github.com/waytotheweb/scripts
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <https://www.gnu.org/licenses>.
###############################################################################
      

Step 1: Installation

cd /usr/src
rm -fv csf.tgz
wget https://fixyourwordpress.com/codex/CSF/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh
      

Next, test whether you have the required iptables modules:

perl /usr/local/csf/bin/csftest.pl
      

Don't worry if all features cannot run, as long as there are no FATAL errors.

Remove conflicting firewall scripts if needed:

sh /usr/local/csf/bin/remove_apf_bfd.sh
      

Configure CSF and LFD via /etc/csf/csf.conf or the CSF User Interface. For cPanel/DirectAdmin, CSF comes preconfigured for standard ports and auto-configures SSH if using a non-standard port.

Step 2: Perl Modules

Install any missing Perl modules depending on your system:

# On RPM based systems:
yum install perl-libwww-perl.noarch perl-LWP-Protocol-https.noarch perl-GDGraph perl-Math-BigInt.noarch

# On APT based systems:
apt-get install libwww-perl liblwp-protocol-https-perl libgd-graph-perl

# Via CPAN:
perl -MCPAN -eshell
cpan> install LWP LWP::Protocol::https GD::Graph
      

Step 3: InterWorx

1. Enable CSF in InterWorx > NodeWorx > Plugins > CSF
2. See the InterWorx section in /etc/csf/readme.txt
      

Step 4: Webmin Module Installation/Upgrade

To install or upgrade the CSF Webmin module:

Install CSF as above
Webmin > Webmin Configuration > Webmin Modules >
From local file > /usr/local/csf/csfwebmin.tgz > Install Module
      

Step 5: Uninstallation

cd /etc/csf
sh uninstall.sh
      

This removes CSF and LFD from your server.