From: Otto Moerbeek Date: Tue, 16 Aug 2022 12:07:27 +0000 (+0200) Subject: Document desired DNS674 behaviour and tweak implementation to adhere to docs. X-Git-Tag: rec-4.8.0-alpha1~53^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e5551f38e778ba0918c809463093cff4106211b;p=thirdparty%2Fpdns.git Document desired DNS674 behaviour and tweak implementation to adhere to docs. --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 0d36ee09e5..5e4bcd7fc7 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1176,15 +1176,18 @@ void startDoResolve(void* p) } } + bool luaHookHandled = false; if (dc->d_luaContext) { PolicyResult policyResult = PolicyResult::NoAction; if (answerIsNOData(dc->d_mdp.d_qtype, res, ret)) { if (dc->d_luaContext->nodata(dq, res, sr.d_eventTrace)) { + luaHookHandled = true; shouldNotValidate = true; policyResult = handlePolicyHit(appliedPolicy, dc, sr, res, ret, pw, tcpGuard); } } else if (res == RCode::NXDomain && dc->d_luaContext->nxdomain(dq, res, sr.d_eventTrace)) { + luaHookHandled = true; shouldNotValidate = true; policyResult = handlePolicyHit(appliedPolicy, dc, sr, res, ret, pw, tcpGuard); } @@ -1196,7 +1199,7 @@ void startDoResolve(void* p) } } // dc->d_luaContext - if (g_dns64Prefix && dc->d_mdp.d_qtype == QType::AAAA && !vStateIsBogus(dq.validationState) && dns64Candidate(dc->d_mdp.d_qtype, res, ret)) { + if (!luaHookHandled && g_dns64Prefix && dc->d_mdp.d_qtype == QType::AAAA && (!shouldNotValidate || !sr.isDNSSECValidationRequested() || !vStateIsBogus(dq.validationState)) && dns64Candidate(dc->d_mdp.d_qtype, res, ret)) { res = getFakeAAAARecords(dq.qname, *g_dns64Prefix, ret); shouldNotValidate = true; } diff --git a/pdns/recursordist/docs/dns64.rst b/pdns/recursordist/docs/dns64.rst index 1f7b9ff105..e6827b81f8 100644 --- a/pdns/recursordist/docs/dns64.rst +++ b/pdns/recursordist/docs/dns64.rst @@ -10,6 +10,24 @@ We do this by retrieving the A records for ``www.example.com``, and translating Elsewhere, a NAT64 device listens on these IPv6 addresses, and extracts the IPv4 address from each packet, and proxies it on. As of 4.4.0, an efficient implementation is built the recursor and can be enabled via the using the :ref:`dns64-prefix setting `. + +Native DNS64 support +-------------------- +Native DNS64 processing will happen after calling a ``nodata`` or ``nxdomain`` Lua hook (if defined), but before calling a ``postresolve`` or ``postresolve_ffi`` Lua hook (if defined). + +To consider native DNS64 processing the following conditions must be met: + +- The :ref:`setting-dns64-prefix` is defined. +- A ``nodata`` or ``nxdomain`` Lua hook did not return ``true``. +- The original query type was ``AAAA``. +- The result code of the ``AAAA`` query was not ``NXDomain``. +- No relevant answer was received: the result code was ``NoError`` with no relevant answer records, or an error unequal to ``NXDomain`` occurred. +- If DNSSEC processing is requested the validation result was not ``Bogus``. + +Before version 4.8.0, only ``NoError`` results were considers candidates for DNS64 processing. + +Scripted DNS64 Support +---------------------- On earlier versions or for maximum flexibility, DNS64 support is included in the :doc:`lua-scripting/index`. This allows for example to hand out custom IPv6 gateway ranges depending on the location of the requestor, enabling the use of NAT64 services close to the user.