From 3798b738b82f56fbb082e6fbfc80ea6e5f04bf45 Mon Sep 17 00:00:00 2001 From: Travis Dent Date: Wed, 25 Sep 2024 17:34:36 -0700 Subject: [PATCH] Pass unmatched queries on configured domain to recursive erver. --- agent/dns.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/agent/dns.go b/agent/dns.go index dd34b3b8bd..42db872471 100644 --- a/agent/dns.go +++ b/agent/dns.go @@ -577,11 +577,20 @@ func (d *DNSServer) handleQuery(resp dns.ResponseWriter, req *dns.Msg) { default: err = d.dispatch(resp.RemoteAddr(), req, m, cfg, maxRecursionLevelDefault) - rCode := rCodeFromError(err) - if rCode == dns.RcodeNameError || errors.Is(err, errNoData) { - d.addSOAToMessage(cfg, m, q.Name) + if errors.Is(err, errNameNotFound) { + // Name matches the configured (root) domain, but doesn't match any nodes. + // Pass upstream to be handled by recursion server, if available. + if m.RecursionAvailable { + d.logger.Debug("request passed to recursor", "name", q.Name) + d.handleRecurse(resp, req) + } + } else { + rCode := rCodeFromError(err) + if rCode == dns.RcodeNameError || errors.Is(err, errNoData) { + d.addSOAToMessage(cfg, m, q.Name) + } + m.SetRcode(req, rCode) } - m.SetRcode(req, rCode) } setEDNS(req, m, !errors.Is(err, errECSNotGlobal))