I've had a long-running v3 recursor that I just migrated to v4.0. I was using a Lua script, specifically the preresolve function, to implement split-horizon functionality. This worked great - but the new syntax for v4.x threw me for a bit.

I've got it working now - and in a far simpler and more elegant script which I really appreciate. My whole script is now:

lanDomains = newDS()
lanDomains:add(dofile("/etc/powerdns/lanDomains"))

function preresolve(dq)
    if(dq.qtype==pdns.A and lanDomains:check(dq.qname)) then
        dq:addAnswer(pdns.A,"192.168.0.4")
        return true
    end
    return false
end

and the "lanDomains" file looks like:

return{
"internaldomain1",
"internaldomain2",
<...>
}

I love it - simple, and an easy way to update with any changes. It so happens that I'm re-directing everything to the same address - but I could easily adapt to handle multiple internal servers. This works because all internal clients use this recursor and have no need to know the external IP - and any external queries go to the authoritative server and aren't affected by the recursor. As far as I know - this is the correct PowerDNS way to implement this. But...

Logically - it seems to me I could/should accomplish the same thing by using the preoutquery() function. Functionally - that turns out not to be the case (I tried using identical code, just changed the name from preresolve()). So - am I misunderstanding the role of preoutquery()?

--
Daniel

_______________________________________________
Pdns-users mailing list
[email protected]
https://mailman.powerdns.com/mailman/listinfo/pdns-users

Reply via email to