CentOS下iptables封IP的命令讲解

乐清SEO_开发应用_Centos_ 乐清SEO2021-04-25 转载自:

查看当天登陆未成功的IP

CentOS下iptables封IP的命令讲解

一条把这些IP全部封掉:

for i in `grep "$(date +"%b %d")" /var/log/secure | grep "Failed password" | awk '{print $(NF-3)}' | sort | uniq -c | sort -nr| awk '{print $2}'` ;do -A INPUT -s $i -j DROP; done

效果:

CentOS下iptables封IP的命令讲解