CSF即ConfigServer Security & Firewall,是 状态包检测(SPI)防火墙,登录/***检测和安全的Linux服务器的应用程序。 是基于SPI的iptables防火墙,具有全面,直接,方便,灵活的配置。
        具有漏洞检测,ip阻止、账户修改跟踪、IDS(***检测系统)、安全检查等等一系列的功能。具体的介绍请查看官方网站:http://www.configserver.com/cp/csf.html。
      CSF可以支持图形化界面配置,当然,是通过控制面板程序,cpanel、DirectAdmin、Webmin
      个人感觉这个工具还是挺强悍的。
支持的系统:
RedHat的V7.3,V8.0,9.0   
openSUSE的V10,V11
RedHat企业V3,V4,V5(32/64位)   
Debian的V3.1,V4,V5 ,V6
CentOS的V3,V4,V5(32/64位)     
Ubuntu的v6.06 LTS,V8.10 ,v9.10,v10.04 LTS,v10.10
V1到V1的Fedora Core 4(32/64位)   
Mandriva的2009 ,2010
Gentoo的   
Slackware的v12.2
CouldLinux(在CentOS / RHEL的基础)

支持虚拟服务器和测试:
Virtuozzo   
OpenVZ
VMware
UML
Xen   
微软虚拟服务器
VirtualBox     
(**需要正确的主​​机服务器上的iptables配置)    

1.下载最新版安装
wget -c  http://www.configserver.com/free/csf.tgz
2.解压
tar -xzvf csf.tgz
然后进入该目录
cd csf
3.安装
执行命令
sh install.sh
注意:安装前需要安装 依赖包,perl-libwww-perl perl iptables  建议你yum安装,即为:
yum install perl-libwww-perl perl iptables
4.测试安装好的csf是否工作正常
perl /etc/csf/csftest.pl
5.开启活关闭csf,并对端口进行限制。
可以直接修改/etc/csf/csf.conf文件进行修改。也可以直接用sed指令,
cd /etc/csf
sed -i 's/^TESTING =.*/TESTING = "0"/' csf.conf
sed -i 's/^TCP_IN =.*/TCP_IN = "21,22,9091,51413,30000:35000"/' csf.conf
sed -i 's/^TCP_OUT =.*/TCP_OUT = "1:65535"/' csf.conf
sed -i 's/^UDP_IN =.*/UDP_IN = "20,21,51413"/' csf.conf
(以上是对tcp和udp的某端口的进出流量进行限制,可以根据你直接的情况修改)
或者使用 控制面板进行图形化界面设置。
配置完以后,要重启csf服务
service csf restart 或者  service csf reload
csf启动文件在/etc/init.d/csf  
补充:
在网上收到这样一个脚本,是给LNMP环境中,使用csf的用户使用的:
#!/bin/bash
#Collecting list of ip addresses connected to port 80
 
netstat -plan|grep :80|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -nk 1 > /root/iplist
 
#Limit the no of connections
LIMIT=15;
 
for ip in `cat /root/iplist |awk '{print $2}'`;do
 
        if [ `grep $ip /root/iplist | awk '{print $1}'` -gt $LIMIT ]
        then
                echo "15 connection from $ip... `grep $ip /root/iplist | awk '{print $1}'` number of connections... Blocking $ip";
 
                #Blocking the ip ...
 
                CHECK_IF_LOCALIP=0;
                /sbin/ifconfig | grep $ip > /dev/null;
                if [ $? -ne $CHECK_IF_LOCALIP ]
                then {
                        FLAG=0;
                        grep $ip /etc/csf/csf.deny > /dev/null;
                        if [ $? -ne $FLAG ]
                        then
                                iptables -I INPUT -s $ip -j DROP;
                                echo "deny $ip;" >> /usr/local/nginx/conf/vhost/block.conf;
                                /usr/sbin/csf -d $ip;
                                ~/lnmp reload;
                        else
                                echo " Ipaddress $ip is already blocked ";
                        fi
                }
                else
                        echo " Sorry, the ip $ip cannot be blocked since this is a local ip of the server ";
                fi
        fi
done

如果使用的是cpanel控制面板程序,在登入以后,左侧最下方,有Plugins,下面就是ConfigServer Security & Firewall(csf),点击以后,在右侧进行管理。
截图说明: