Linux 的一般过滤 手段
软件本身过滤----TCP wapper-----iptables----硬件防火墙
|
语法简单,立刻生效
无法细致到具体的端口,只能管理系统注册的一些服务
有一定的局限性。
思考: ssh ,如果某个 IP地址,连续 三次 输入错误密码,
直接屏蔽该 IP 地址的 TCP 连接, 防止它暴力猜测密码。
应用场景: 用户 远程连接 ,只要输错 3次以上密码,就会被 屏蔽连接 ,防止暴力猜测密码 ======
[root@proxy-86 /test]# cat ssh-mon.sh
#!/bin/bash
while [ 1 -lt 2 ]
do
sleep 3
bad_ip=`lastb | grep "ssh:" | awk '{print $3}' | sort | uniq -c | awk '$1>=3{print $2}'`
for ip in `echo $bad_ip`
do
count=`cat /etc/hosts.allow | grep "^sshd:$ip:deny$" | wc -l`
if [ $count -eq 0 ]
then
echo "sshd:$ip:deny" >> /etc/hosts.allow
else
continue
fi
done
done