How to install CSF (ConfigServer Security & Firewall) in VULTR VPS

Step 1: Installing Required CSF Modules

Install required Perl modules for CSF script, otherwise you will see an error like libwww not being installed.

Step 2: Downloading CSF

It’s very good idea to use /tmp directory when downloading or installing any new software’s. Use Wget command to download the CSF script.

Step 3: Removing Existing Firewall

Remove if you are using any other iptables firewall scripts like APF (Advanced Policy Firewall) or BFD (Brute Force Detection), because you should not run both the firewall scripts on same server otherwise they will conflict with each other horribly. So, to prevent such conflicts you must remove both the combination APF+BFD by running un-install script provided by CSF module.

Step 4: Installing CSF

Once the download completes, extract the all the files using Tar command and change to newly created CSF directory. Then run the installer script to install it.

Step 5: Configuring CSF

The above script will install and starts CSF in a “Testing” mode. Which means it doesn’t fully protect your server from anything. To disable “Testing” mode you need to configure your CSF for TCP_IN, TCP_OUT, UDP_IN and UDP_OUT options that best suits your requirements. Open the file called /etc/csf/csf.conf and make following changes.

Once you happy with your CSF configuration, you can disable “Testing” mode by changing variable TESTING = “1” to TESTING = “0”. But before changing it, I highly recommend you to read complete CSF readme file at

Step 6: Starting CSF

Now it’s ready to start the csf daemon and enable csf to start at reboot time.

Step 7: CSF Configuration Options and Usage

These following options are used to modify and control csf configuration. All the configuration files of csf are located under /etc/csf directory. If you modify any of the following files you will need to restart the csf daemon to take changes.

  1. csf.conf : The main configuration file for controlling CSF.
  2. csf.allow : The list of allowed IP’s and CIDR addresses on the firewall.
  3. csf.deny : The list of denied IP’s and CIDR addresses on the firewall.
  4. csf.ignore : The list of ignored IP’s and CIDR addresses on the firewall.
  5. csf.*ignore : The list of various ignore files of users, IP’s.

Step 8: CSF Commands and Options

Some of the common command line options to add or deny IP addresses. option -d is used to deny an IP address, option -a is used to allow an IP address and option -r is used to reload all rules.

If in-case, you have forgotten csf commands, just type csf on the terminal you will get the list of all the options.

That’s it, finally you have managed to installed and configured your firewall successfully. If you’re facing any trouble while installing just post your queries using our comment section below, we will love to solve all your queries.

Step 9: Remove CSF Firewall

If you would like to remove CSF firewall completely, just run the following script located under /etc/csf/ directory.

The above command will erase CSF firewall completely with all the files and folders.


Source: tectmint