How to install ConfigServer Firewall to cPanel/WHM?

The ConfigServer Firewall - CSF is one of the most popular and advanced firewall suite available for Linux machines. Though it has more advanced configuration options, it's too easy to install and flexible to configure. This article will guide you to install CSF. Please note that, following tutorial is only applicable to VPS or Dedicated server customers.

Login to your server via SSH with root user and retrieve the CSF package files using wget command.


Unpack the downloaded archive.

 tar xfz csf.tgz

Navigate to the uncomperssed csf directory.

 cd csf

Run the installer.


It will create configuration file and add necessary cPanel services to allow list. Once firewall is installed, you will see message similar to following.

TCP ports currently listening for incoming connections:

UDP ports currently listening for incoming connections:

Note: The port details above are for information only, csf hasn't 
been auto-configured.

Don't forget to:
1. Configure the TCP_IN, TCP_OUT, UDP_IN and UDP_OUT options in 
the csf configuration to suite your server
2. Restart csf and lfd
3. Set TESTING to 0 once you're happy with the firewall

Adding current SSH session IP address to the csf whitelist in csf.allow:
Adding to csf.allow only while in TESTING 
mode (not iptables ACCEPT)
*WARNING* TESTING mode is enabled 
- do not forget to disable it in the configuration

Installation Completed

Start CSF testing mode by following command.

/etc/init.d/csf restart

Once you finish the testing, bring CSF out of testing mode by editing csf.conf file. Open this file in any editor of your choice. We have used nano editor to edit this file as follows.

 nano /etc/csf/csf.conf

At top of this file, you will find following text block.

# server! Then do remember to set it to 0 and restart csf when you're sure
# everything is OK. Stopping csf will remove the line from /etc/crontab

Edit the last line of this block and save the changes.


Restart the CSF. That's it, your CSF firewall is up and running.

/etc/init.d/csf restart

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

Fix :: file open /home/user/etc/domainname/passwd failed with error no such file or directory

Problem Statement Getting error while creating an email account from cPanel. Error Message...

Fatal error: Call to undefined function mysqli_connect() in /home/user/public_html/includes/connection.php

Error Message Fatal error: Call to undefined function mysqli_connect() in...

How to Set the Server Time Zone in WHM?

We deliver Linux VPS with default Timezone i.e. MST – Mountain Standard Time. You may need to...

How to Create Reseller Account in WHM?

WHM allows you to create reseller accounts under your cPanel Linux VPS. To create reseller...

SMTP error while using PHPMailer with GMail Authentication

Problem Statement One of our Linux VPS customer was unable to send emails through PHPMailer...