0

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?

1 Answer 1

1

Remove "destination" from the function arguments.

From https://doc.powerdns.com/md/recursor/scripting/, preresolve() takes only three arguments

preresolve ( remoteip, domain, qtype )

1
  • Thank you Jemshad! Since it has been almost a year since I asked the question I unfortunately don't possess the environment I used to, so it is hard for me to verify your answer.
    – azzid
    Apr 30, 2015 at 10:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .