[Pdns-users] Recursor and LUA scripting: I don't understand why preresolve answering a CNAME won't cascade to other records
Oscar Koeroo
okoeroo at gmail.com
Sun May 31 10:08:36 UTC 2020
Hi,
I’m using my the Recursor version 4.3.1 on my Pi and building the following. I have a VPS and a home-server. I use “domain.net” for the internet access and in my home I use “domain.local”.
Due to NAT and how my home router works, I intercept the DNS requests and provide a local answer instead of the WAN IP address for example. In other case I would like to use “domain.net”
I’m using the following LUA script to intercept, but I don’t understand the results. Why doesn’t the dig get the CNAME to got to the A record I have in my domain.local zone? I expected dig to try to get the CNAME value of qr.domain.net and the CNAME value of that result, which seems to halt there.
The expected result I was looking for was:
dig qr.domain.net
;; ANSWER SECTION:
qr.domain.net. 3600 IN CNAME qr.domain.local.
qr.domain.local. 41584 IN CNAME apps.domain.local.
apps.koeroo.local. 40931 IN A 192.168.1.28
- EOL
I got:
dig qr.domain.net
;; ANSWER SECTION:
qr.domain.net. 3600 IN CNAME qr.domain.local.
- EOL
dig cloud.domain.net
;; ANSWER SECTION:
cloud.domain.net. 3600 IN A 192.168.1.15
- EOL
Script:
function preresolve(dq)
if dq.qtype == pdns.A then
if (dq.qname:toString() == "cloud.domain.net.") then
pdnslog("preresolve: " .. dq.qname:toString(), pdns.loglevels.Info)
dq:addAnswer(pdns.A, "192.168.1.15")
dq.rcode = pdns.NOERROR
return true
elseif (dq.qname:toString() == "vpn.domain.net.") then
pdnslog("preresolve: " .. dq.qname:toString(), pdns.loglevels.Info)
dq:addAnswer(pdns.A, "192.168.1.37")
dq.rcode = pdns.NOERROR
return true
elseif (dq.qname:toString() == "qr.domain.net.") then
pdnslog("preresolve: " .. dq.qname:toString(), pdns.loglevels.Info)
dq:addAnswer(pdns.CNAME, "qr.domain.local")
dq.rcode = pdns.NOERROR
return true
end
end
return false
end
Oscar Koeroo
More information about the Pdns-users
mailing list