最近被美国IP盯上了,瞄的不间断攻击ADD-TO-CART页面。记录下用IPSET屏蔽过程。
安装组件:
apt-get install ipset
去IPDENY.COM下载US地址:
wget https://www.ipdeny.com/ipblocks/data/countries/us.zone -O us.zone
执行如下脚本,将IP地址段中的记录转换为Ipset指令,保存在 ipset_result.sh
可执行文件中
for i in `cat us.zone`; do echo "ipset add blockus $i" >>ipset_result.sh; donechmod +x ipset_result.sh
创建上面的IPSET集合blockus:
ipset create blockus hash:net hashsize 10000 maxelem 1000000
sh ipset_result.sh
检查下有多少条数据:
ipset list block | wc -l
最后封杀US集合:
sudo iptables -I INPUT -m set --match-set blockus src -j DROP.