I have a server (Ubuntu 12.04) where I run powerdns-recursor.
I'm trying to add some logic to certain requests and have got my target set on lua scripting for powerdns.
I don't seem to be able to get it to work though.
I guess/hope that the version of the recursor that is available in the ubuntu repositories has the lua support compiled in. I find it likely that that is the case since liblua5.1-0 is a requirement for the package. Also, when I reload the lua script I seem to get sane output:
$ sudo rec_control reload-lua-script
ok, reload/unload queued
I've created a lua file and set up my configuration to load it:
$ grep lua /etc/powerdns/recursor.conf
# lua-dns-script Filename containing an optional 'lua' script that will be used to modify dns answers
lua-dns-script=/etc/powerdns/script.lua
I've added one example script to the file and reloaded the server.
The example script is:
$ cat /etc/powerdns/script.lua
function preresolve ( ip, destination, domain, qtype )
if domain == "the.time."
then
d=os.date("\"%c\"")
ret={
{qtype="16", ttl=1, place="1", content=d},
}
if qtype == pdns.TXT
then
return 0, ret
else
return -1, {}
end
end
return -1, {}
end
function nxdomain ( ip, destination, domain, qtype )
return -1, {}
end
But when I request the 'the.time'-record I don't get the desired result:
$ nslookup -type=TXT the.time. 1.2.3.4
Server: 1.2.3.4
Address: 1.2.3.4#53
** server can't find the.time.: NXDOMAIN
What am I missing?