Linux_服务器_禁止国外IP访问

时间:2021-04-19 15:10:27   收藏:0   阅读:0

这里我们以禁止美国地址段为例,可以根据自己的需要将us.zone改为相应国家缩写


#/bin/bash
wget -O /tmp/us.zone http://www.ipdeny.com/ipblocks/data/countries/us.zone
for ip in `cat /tmp/us.zone`
do

iptables -I INPUT -s $ip -j DROP
done

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!