How to install ConfigServer Security & Firewall (CSF) on CentOS

steitieh

Well-known member
Joined
Apr 23, 2014
Messages
113
Points
18
ConfigServer Security & Firewall (or CSF) is a very popular firewall and effectively used on current Linux servers. Besides the basic features such as a firewall, CSF also has advanced security functions, such as preventing flood login, port scans, SYN floods...etc

how-to-install-CSF-Firewall-on-centos.jpg

Installing CSF Firewall

1. Install modules required for CSF

Install module Perl for CSF script

Code:
yum install perl-libwww-perl
2. Download CSF

Code:
cd /tmp
wget http://www.configserver.com/free/csf.tgz
3. Install CSF

Proceed to extract and install CSF

Code:
tar -xzf csf.tgz
cd csf
sh install.sh
4. Configure CSF

By default, the script will install and running the CSF in "Testing" mode, which means the server has not been full protection. To turn off the "Testing" you need to configure the option TCP_IN, TCP_OUT, UDP_IN and UDP_OUT to suit demand.

Open the configuration file of CSF

Code:
nano /etc/csf/csf.conf
Edit the appropriate parameters

Code:
# Allow incoming TCP ports
TCP_IN = "20,21,22,25,53,80,110,143,443,465,587,993,995"

# Allow outgoing TCP ports
TCP_OUT = "20,21,22,25,53,80,110,113,443"

# Allow incoming UDP ports
UDP_IN = "20,21,53"

# Allow outgoing UDP ports
# To allow outgoing traceroute add 33434:33523 to this list
UDP_OUT = "20,21,53,113,123"
When you configured completely, turn off by switching Testing = "1" to TESTING = "0"

TESTING = "0"

Finally saved configuration file CSF

5. Run the CSF

Running CSF and allows self activated each time the boot VPS

Code:
chkconfig --level 235 csf on
service csf restart
6. The configuration file CSF

Complete information management configuration and CSF files are saved in the folder /etc/csf. If you edit this file, then restart CSF need to change to take effect.

csf.conf: The configuration file for managing the CSF.
csf.allow: List of IP addresses allowed through the firewall.
csf.deny: List of IP addresses through the firewall rejected.
csf.ignore: List of IP addresses allowed through the firewall and are not blocked if there are problems.
csf. * ignore: A list of the user, the IP is ignore.

7. Some commands

Some commands used to add (-a) or deny (-d) IP address.

Code:
csf -d IPADDRESS //Block an IP address
csf -dr IPADDRESS // delete an IP that blocked before.
csf -a IPADDRESS // Allow an IP
csf -ar IPADDRESS // delete an IP that allowed
csf -g IPADDRESS // check an IP is blocked or not.
csf -r // restart CSF
csf -x // turn off CSF
csf -e //Open CSF
In case you forget the above command, use csf will list the entire list of options.

8. Remove CSF

If you want to completely remove CSF, just use the following script:

Code:
/etc/csf/uninstall.sh
This will delete the entire CSF, you should consider before doing this action. If you want to temporarily disable CSF, then transferred to 1 in TESTING mode.

If you have any other ideas, please write down, I look forward to read all your comments about isntall and configurating CSF.

Thanks
 

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top