Iptables拒绝指定国家的IP访问
2266 点击·0 回帖
![]() | ![]() | |
![]() | 有些服务器需拒绝特定国家的IP访问,可使用Iptables配合ipdeny提供的各个国家IP段为源进行过滤操作,由于数目较多会影响iptables性能,也可使用高效率Iptablesgeoip模块进行匹配操作。 应用示例,以拒绝美国IP为例: #/bin/bash wget -O /tmp/us.zonehttp://www.ipdeny.com/ipblocks/data/countries/us.zone forip in `cat /tmp/us.zone` do Blocking $ip iptables -I INPUT -s $ip -jDROP done | |
![]() | ![]() |