pdns-recursor lua preresolve脚本无法正常工作

我正在尝试让pnds-recursor在查询来自内部网络时将主机名解析为不同的A记录(因为这将通过VPN进行路由)。

为此,我设置了一个实现preresolve函数的LUA脚本:

 pdnslog(“ pdns-recursor Lua脚本开始!”,pdns.loglevels.Warning)

function preresolve(dq)
 if dq.qtype == pdns.A 
 then
 if dq.qname:equal(“<host.to.resolve>”)
 then
 dq.rcode=0-使它成为普通答案
 netMask = newNMG()
 netMask:addMask(“172.28.0.0/14”)
 netMask:addMask(“xxxx:xxx:5:f1:0:0:0:0/64”)
 if netMask:match(dq.remoteaddr)
 then
 dq:addAnswer(pdns.A,“<internal IP>”)
 else
 dq:addAnswer(pdns.A,“<public IP>”)
 end
 return true
 end
 end
 return false
end

现在奇怪的是:对于一些来自192.168.23.x的客户端,这个方法有效,而对于其他人,它返回内部IP,尽管客户端的远程IP不在上述指定的范围内。

有没有人知道为什么它没有像预期那样工作?

谢谢

点赞
用户5546074
用户5546074

好的,确实在 recursor.conf 中使用以下选项

disable-packetcache=yes

解决了问题。以防万一其他人遇到类似的问题。

2020-03-20 09:54:50