Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2226273
  • 博文数量: 533
  • 博客积分: 8689
  • 博客等级: 中将
  • 技术积分: 7046
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-26 10:00
文章分类

全部博文(533)

文章存档

2024年(2)

2023年(4)

2022年(16)

2014年(90)

2013年(76)

2012年(125)

2011年(184)

2010年(37)

分类: LINUX

2010-11-26 10:12:19

#!/bin/bash
cat /root/block.txt |while  read  block
do
iptables -A INPUT -p tcp -m tcp   -s $block --dport 80 -j REJECT
iptables-save
/etc/rc.d/init.d/iptables-save
done








#/bin/bash

netstat -an| grep :80 | grep -v 127.0.0.1 |awk '{ print $5 }' | sort|awk -F: '{print $1,$4}' | uniq -c | awk '$1 >50 {print $1,$2}' > /root/black.txt

for i in `awk '{print $2}' /root/black.txt`

do

COUNT=`grep $i /root/black.txt | awk '{print \$1}'`

DEFINE="50"

ZERO="0"

if [ $COUNT -gt $DEFINE ];

then

grep $i /root/white.txt > /dev/null

if [ $? -gt $ZERO ];

then

echo "$COUNT $i"

iptables -I INPUT -p tcp -s $i -j DROP 

fi

fi

done





iptables -I INPUT -p tcp --dport 80 -m connlimit --connlimit-above 10 -j DROP  限制单个地址并发连接数不大于50
iptables -I INPUT -p tcp --dport 80 -m connlimit --connlimit-above 10 --connlimit-mask 24 -j DROP 限制一个C类网段的并发连接数
阅读(1389) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:Iptables 规则 一些简单实例和详细介绍

给主人留下些什么吧!~~