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配置)
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
#!/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
![](../p_w_upload/201107/170736966.jpg)