PowerDNS Recursor LUA Layer

Hello! Yesterday i wrote script on LUA to rewrite records before resolve the request.
Recursor has LUA scripting support if you are install it with lua feauture support and configure with lua-dns-script.
LUA script for this target:

function preresolve ( remoteip, domain, qtype, qname )
print ("prequery handler called for: ", remoteip, "local: ", getlocaladdress(), domain, qtype)
if (matchnetmask(remoteip, {"YOUR_NETWORK"}) and domain == "YOUR_DOMAIN.") then
-- pdnslog("Rewrite RECORD to "..domain.." from "..remoteip.." on "..getlocaladdress(), pdns.loglevels.Info);
local ret={}
ret[1]= {qtype=pdns.A, content="ADDRESS_TO_REWRITE", ttl=YOUR_TTL_NOT_REQUIRED}
print "dealing!"
return 0, ret
print "not dealing!"
return pdns.PASS, {}

Leave a Reply