PDNS默认不支持bind view功能,通过PowerDNS Recursor加载Lua脚本判断再递归查询PowerDNS实现智能DNS。
#关闭数据包缓存,测试时开启查询时直接读缓存不经过lua preresolve()
disable-packetcache=yes
forward-zones=com=108.61.242.102
local-address=0.0.0.0
lua-dns-script=/tmp/b.lua
#转发所有域到pdns server
forward-zones=.=127.0.0.1:54
lua:
function preresolve ( remoteip, domain, qtype )
pdnslog("a test message.. received query "..domain.." from "..remoteip.." on "..getlocaladdress());
ret={}
if qtype ~= pdns.A then return -1, ret end --非A记录查询跳过,后端查询
local ips = {"192.168.1.1/32", "10.1.0.0/16", "127.0.0.0/24"}
if matchnetmask(remoteip, ips) and domain == "www.example.com."
then
ret[1]= {qtype=pdns.A, content="85.17.220.215", ttl=86400}
setvariable()
return 0, ret
else
setvariable()
return -1, ret
end
end
标签:none