一、IP归属地数据库中导出需要的地址段列表
二、安装ipset
三、建立access白名单
ipset create access hash:net
四、导入IP地址
use strict;
open INPUT,"output.txt";
while (<INPUT>){
my $line=$_;
chomp $line;
system ("ipset add access $line");
}
close INPUT;五、设置iptables规则
iptables -A INPUT -m set --match-set access src -p udp --destination-port 53 -j ACCEPT iptables -A INPUT -p udp --destination-port 53 -j DROP
本文出自 “如意灵临” 博客,请务必保留此出处http://417722381.blog.51cto.com/7856838/1971479
原文地址:http://417722381.blog.51cto.com/7856838/1971479