<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,sans-serif">Hi,</div><div class="gmail_default" style="font-family:arial,sans-serif">If I'm not wrong you need to tell pdns to resolve the CNAME: <a href="https://doc.powerdns.com/recursor/lua-scripting/hooks.html#cname-chain-resolution" style="font-family:Arial,Helvetica,sans-serif">https://doc.powerdns.com/recursor/lua-scripting/hooks.html#cname-chain-resolution</a></div><div class="gmail_default" style="font-family:arial,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,sans-serif">Regards,</div><div class="gmail_default" style="font-family:arial,sans-serif">Roman</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am So., 31. Mai 2020 um 12:08 Uhr schrieb Oscar Koeroo via Pdns-users <<a href="mailto:pdns-users@mailman.powerdns.com">pdns-users@mailman.powerdns.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
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 “<a href="http://domain.net" rel="noreferrer" target="_blank">domain.net</a>” for the internet access and in my home I use “domain.local”.<br>
<br>
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 “<a href="http://domain.net" rel="noreferrer" target="_blank">domain.net</a>” <br>
<br>
<br>
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 <a href="http://qr.domain.net" rel="noreferrer" target="_blank">qr.domain.net</a> and the CNAME value of that result, which seems to halt there.<br>
<br>
<br>
<br>
<br>
The expected result I was looking for was:<br>
<br>
<br>
dig <a href="http://qr.domain.net" rel="noreferrer" target="_blank">qr.domain.net</a><br>
<br>
;; ANSWER SECTION:<br>
<a href="http://qr.domain.net" rel="noreferrer" target="_blank">qr.domain.net</a>.          3600    IN      CNAME   qr.domain.local.<br>
qr.domain.local.        41584   IN      CNAME   apps.domain.local.<br>
apps.koeroo.local.      40931   IN      A       192.168.1.28<br>
- EOL<br>
<br>
<br>
<br>
I got:<br>
<br>
<br>
dig <a href="http://qr.domain.net" rel="noreferrer" target="_blank">qr.domain.net</a><br>
<br>
;; ANSWER SECTION:<br>
<a href="http://qr.domain.net" rel="noreferrer" target="_blank">qr.domain.net</a>.          3600    IN      CNAME   qr.domain.local.<br>
- EOL<br>
<br>
<br>
dig <a href="http://cloud.domain.net" rel="noreferrer" target="_blank">cloud.domain.net</a><br>
<br>
;; ANSWER SECTION:<br>
<a href="http://cloud.domain.net" rel="noreferrer" target="_blank">cloud.domain.net</a>.       3600    IN      A       192.168.1.15<br>
- EOL<br>
<br>
<br>
<br>
Script:<br>
<br>
function preresolve(dq)<br>
    if dq.qtype == pdns.A then<br>
        if (dq.qname:toString() == "<a href="http://cloud.domain.net" rel="noreferrer" target="_blank">cloud.domain.net</a>.") then<br>
            pdnslog("preresolve: " .. dq.qname:toString(), <a href="http://pdns.loglevels.Info" rel="noreferrer" target="_blank">pdns.loglevels.Info</a>)<br>
            dq:addAnswer(pdns.A, "192.168.1.15")<br>
            dq.rcode = pdns.NOERROR<br>
            return true<br>
        elseif (dq.qname:toString() == "<a href="http://vpn.domain.net" rel="noreferrer" target="_blank">vpn.domain.net</a>.") then<br>
            pdnslog("preresolve: " .. dq.qname:toString(), <a href="http://pdns.loglevels.Info" rel="noreferrer" target="_blank">pdns.loglevels.Info</a>)<br>
            dq:addAnswer(pdns.A, "192.168.1.37")<br>
            dq.rcode = pdns.NOERROR<br>
            return true<br>
        elseif (dq.qname:toString() == "<a href="http://qr.domain.net" rel="noreferrer" target="_blank">qr.domain.net</a>.") then<br>
            pdnslog("preresolve: " .. dq.qname:toString(), <a href="http://pdns.loglevels.Info" rel="noreferrer" target="_blank">pdns.loglevels.Info</a>)<br>
            dq:addAnswer(pdns.CNAME, "qr.domain.local")<br>
            dq.rcode = pdns.NOERROR<br>
            return true<br>
        end<br>
    end<br>
    return false<br>
end<br>
<br>
<br>
Oscar Koeroo<br>
<br>
<br>
<br>
_______________________________________________<br>
Pdns-users mailing list<br>
<a href="mailto:Pdns-users@mailman.powerdns.com" target="_blank">Pdns-users@mailman.powerdns.com</a><br>
<a href="https://mailman.powerdns.com/mailman/listinfo/pdns-users" rel="noreferrer" target="_blank">https://mailman.powerdns.com/mailman/listinfo/pdns-users</a><br>
</blockquote></div></div>