CSF firewall commonly known as Configserver Security and Firewall has become one of the popular firewall not just because of its easy of use it also provides a cpanel interface and can be easily installed and tuned by any novice users. If you are running cpanel without firewall then CSF firewall is very much recommended, considering the security aspects of your server.

You can visit the CSF firewall website for more information. You can also download necessary files there.

Important Features

WHM Interface for CPanel

Firewall Running Status

Easy to Install and Administer

Brute Force Attack Prevention

One Click Server Security Checks

Port scan prevention and blocking

Intrusion detection system

Easy Installation and Configuration

IP Blocking and more…

The CSF comes with the LFD, which would detect any malicious login attempts to the server, via

  • courier imap and pop3
  • ssh
  • non-ssl cpanel / whm / webmail
  • pure-pftd
  • password protected web pages (htpasswd)
  • mod_security failures
  • Port Scan

This is an additional feature to the packet filtering. With the Firewall installed, the need for manual intervention is reduced.

Let us prepare a linux based server running with cpanel. Note that CSF firewall requires to remove any currently running IP based firewall (APF or other IP tables firewall). It comes with all necessary scripts that will remove APF or IP tables firewall.


1. Download the package to the server.

2. Extract it.

3. Run the Install script.

Or for cPanel Servers :

Or for DirectAdmin Servers :

That’s it! wait until the script ends!

4. Remove APF or IPTables Firewall

If you have any existing IP tables firewall remove them using uninstall scripts located at /etc/csf. In this case i was running APF firewall and BFD in my server so i have to remove it.

5. Start the Firewall in Testing Mode

Start the firewall with the following command.

If you are running a VPS plan, then you might get the error like this

To fix:

That’s all! Now restart the firewall.

6. Specify which ports you want to allow.

The default ports will be enabled/opened when you install using the above mentioned scripts. If you are using any custom ports, you may need to open in it in the CSF.

It is very important to check the firewall on which ports to open and close all remaining port numbers. Open the /etc/csf/csf.conf and edit the following line with port numbers

For more information about commonly used port numbers refer to this article : Commonly Used Port Numbers

7. Disable the Testing Mode and Start the Firewall

Remember by default the firewall is running in testing mode. You might want to disable the firewall running in testing mode.

Look for the first line and set testing mode to “0”

You may also set the following:

Now restart the firewall!

In Cpanel:

If you have successfully installed the CSF firewall, then you will find this CSF Security & Firewall option within cpanel WHM at the bottom of the menu. Just click on the link and you can also edit the firewall settings inside Cpanel, which is very easy to do.

Configuration Files

Final Steps

1. Check the status of firewall inside cpanel

2. Harden the firewall security by performing the system security check. To do this go to Cpanel WHM > CSF Firewall & Security > Check System Security. There it will list WARNINGS based on your server.

Uninstall CSF

Just run the uninstall script located at the installation directory.