[Pdns-users] use of pdnslog() in pdns-recursor lua scripts

Kenneth Marshall ktm at rice.edu
Fri Jul 16 21:16:36 UTC 2010


Hello PDNS community,

I have been trying to get the pdnslog() function to work
in my lua script for the pdns-recursor. Here is my current
script. Originally it was like the example script:

function preresolve ( remoteip, domain, qtype )
        print ("prequery handler called for: ", remoteip, getlocaladdress(), dom
ain, qtype)
        pdnslog("a test message.. received query from "..remoteip.." on "..getlo
caladdress());
        if domain == "www.mybad.org." 
        then
                print "dealing - faking www.mybad.org"
                return pdns.NXDOMAIN, {}
        else
                return -1, {}
        end
end

And this did successfully log the "a test message..." in the
local3 via syslog. I changed it to:

function preresolve ( remoteip, domain, qtype )
        if domain == "www.bad1.com." 
        then
                print "dealing - phishing www.bad1.com"
                pdnslog("dealing - phishing www.bad1.com");
                return pdns.NXDOMAIN, {}
        elseif domain == "www.bad2.com."
        then
                print "dealing - phishing www.bad2.com"
                pdnslog("dealing - phishing www.bad2.com");
                return pdns.NXDOMAIN, {}
        else
                return -1, {}
        end
end

While it successfully returns NXDOMAIN, it is not logging
to syslog local3. Does anyone have any ideas about what is
going wrong? Is my syntax correct?

Thank you for any assistance.
Regards,
Ken




More information about the Pdns-users mailing list