<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 07/02/2025 10:31, Pavel Prostin via
      Pdns-users wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAMYbbAhTsjaJxPjRWX0ormPc-puwPfOqfdoKoLpqQGwVJrme5w@mail.gmail.com"><br>
      I’m trying to configure the PowerDNS recursor to failover on
      NXDOMAIN. Here is the scenario:<br>
      <br>
      There are two DNS zones: internal and external. The problem is
      that *.<a href="http://example.com" moz-do-not-send="true">example.com</a>
      can either be used for an internal or an external host, and thus
      the record can exist on any DNS server.<br>
      <br>
      Possible workaround: A client tries to resolve the hostname using
      the primary (internal) DNS first. If the internal DNS server has
      no record or cannot resolve the host because it is external and
      returns NXDOMAIN (non-existent domain), a second request is then
      made to the alternate (external) DNS server (this is not the
      secondary DNS fallback) to resolve the domain/host.<br>
      <br>
      I understand that this approach is not RFC-compliant and is not
      the recommended solution (e.g., using .<a
        href="http://internal.example.com" moz-do-not-send="true">internal.example.com</a>
      for internal hosts). However, I attempted to implement it using a
      custom LUA script (see below), which unfortunately does not work
      as intended.<br>
      <br>
      Is the intended solution feasible and scalable?</blockquote>
    <p>I don't think it is. However, if you are forced to use split DNS
      in your environment (meaning that foo.example.com resolves
      differently for internal and external users), I can offer a better
      alternative.</p>
    <p>On your internal recursor, use a Response Policy Zone (RPZ) to
      set the responses which should be seen for *.example.com for
      internal users.  Then any names which are not listed here will
      automatically fall through to the external domain.</p>
    <p>I've done this successfully with bind9. I've never tried it with
      pdns-recursor but it appears to be fully supported:<br>
    </p>
    <p><a class="moz-txt-link-freetext" href="https://doc.powerdns.com/recursor/lua-config/rpz.html">https://doc.powerdns.com/recursor/lua-config/rpz.html</a><br>
    </p>
    <p>HTH,</p>
    <p>Brian.<br>
    </p>
  </body>
</html>