惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
博客园 - 叶小钗
The Cloudflare Blog
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
小众软件
小众软件
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
美团技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
量子位
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
宝玉的分享
宝玉的分享

dnsmasq-discuss

[Dnsmasq-discuss] Announce: dnsmasq-2.92rc2 Re: [Dnsmasq-discuss] [PATCH] Fix arguments order for chaos subdomain check Re: [Dnsmasq-discuss] patch: block-file/allow-file - for review/feedback Re: [Dnsmasq-discuss] patch: block-file/allow-file - for review/feedback Re: [Dnsmasq-discuss] patch: block-file/allow-file - for review/feedback Re: [Dnsmasq-discuss] patch: block-file/allow-file - for review/feedback [Dnsmasq-discuss] patch: block-file/allow-file - for review/feedback Re: [Dnsmasq-discuss] server= with interface parameter changes behavior over time [Dnsmasq-discuss] NFTsets and hosts-files [Dnsmasq-discuss] [PATCH] Allow expired RRSIGs when stale caching is enabled [Dnsmasq-discuss] [PATCH] Fix local host records being overridden by upstream NXDOMAIN [Dnsmasq-discuss] [PATCH] Fix arguments order for chaos subdomain check Re: [Dnsmasq-discuss] Malformed RRSIG Can Crash dnsmasq [Dnsmasq-discuss] Malformed NSEC/NSEC3 Can Hang dnsmasq [Dnsmasq-discuss] Malformed RRSIG Can Crash dnsmasq [Dnsmasq-discuss] Security - IMPORTANT Re: [Dnsmasq-discuss] Issue with circuit-id matching on dhcp requests Re: [Dnsmasq-discuss] Issue with circuit-id matching on dhcp requests Re: [Dnsmasq-discuss] Issue with circuit-id matching on dhcp requests [Dnsmasq-discuss] Issue with circuit-id matching on dhcp requests Re: [Dnsmasq-discuss] [PATCH] bpf.c: fix memory leak in arp_enumerate() on BSD Re: [Dnsmasq-discuss] [PATCH] bpf.c: fix memory leak in arp_enumerate() on BSD Re: [Dnsmasq-discuss] dnssec problem here and now Re: [Dnsmasq-discuss] dnssec problem here and now [Dnsmasq-discuss] dnssec problem here and now Re: [Dnsmasq-discuss] server= with interface parameter changes behavior over time Re: [Dnsmasq-discuss] [PATCH] bpf.c: fix memory leak in arp_enumerate() on BSD Re: [Dnsmasq-discuss] [PATCH] bpf.c: fix memory leak in arp_enumerate() on BSD Re: [Dnsmasq-discuss] [PATCH] Preserve existing log file permissions when adding group-write bit. [Dnsmasq-discuss] server= with interface parameter changes behavior over time
[Dnsmasq-discuss] Bug with NS records when using dnsmasq ...
Thomas Erbesdobler via Dnsmasq-discuss · 2026-02-26 · via dnsmasq-discuss
Hi all,

I think I've found a bug when using dnsmasq as authoritative nameserver (e.g. to automatically provide RRs for local DHCP clients) when querying the NS RR. In particular I'm using dnsmasq with an auth-zone entry, auth-sec-servers, and an auth-server entry without specifying an interface (such that dnsmasq will still recurse on all interfaces). The config is similar to the one below (though I've changed some fields for anonymity):

interface=<some interface>
bind-interfaces
local=/nonexistingbanana/
domain=nonexistingbanana
no-hosts
#no-resolv
dhcp-range=192.168.0.150,192.168.0.254,12h
server=127.0.0.53
auth-zone=nonexistingbanana.
auth-server=ns1.<externally visible domain>.
auth-sec-servers=ns1.<externally visible domain>.,ns2.<externally visible domain>.
auth-peer=192.168.1.173
auth-soa=20260225153310,<some contact>,7200,1,8

This config might not be minimal to reproduce the issue. To give some context: dnsmasq will be used as a "hidden master", and ns1 will AXFR from it - hence it's required to be specified in auth-server such that the SOA RR will be correct.

Now, if one queries the NS records, dnsmasq returns the following:

;; ANSWER SECTION:
ns2.rbg.tum.de.        600    IN    NS I\137\198H\133\192\015\132\250\236\255\255\139\@4\168\@u\029\168\016\015\132\235\236\255\255H\139\021\244s\002. ns1.rbg.tum.de.        600    IN    NS I\137\198H\133\192\015\132\250\236\255\255\139\@4\168\@u\029\168\016\015\132\235\236\255\255H\139\021\244s\002.

Note that the result is correct if one specifies an interface in the auth-server config option (even if the interface does not exist). It looks like this strange behavior is caused by a bug in the name compression logic. The following patch seems to fix it:

diff --git a/src/auth.c b/src/auth.c
index 7c34522..b95e61a 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -669,14 +669,19 @@ size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, time_t n

          if (!subnet)
            for (secondary = daemon->secondary_forward_server; secondary; secondary = secondary->next)
-             if (add_resource_record(header, limit, &trunc, offset, &ansp,
-                                     daemon->auth_ttl, NULL, T_NS, C_IN, "d", secondary->name))
+           {
+             newoffset = ansp - (unsigned char *)header;
+             if (add_resource_record(header, limit, &trunc, -offset, &ansp,
+                                     daemon->auth_ttl, NULL, T_NS, C_IN, "d", offset == 0 ? authname : NULL, secondary->name))
                {
+                 if (offset == 0)
+                   offset = newoffset;
                  if (ns)
                    anscount++;
                  else
                    authcount++;
                }
+           }
        }

       if (axfr)


I think the bug might have been introduced in git commit b43585c34baf0c5eb478aa07423da534b2118536 , which made a similar add_resource_record call for adding the "primary nameserver" (the one in the SOA RR) conditional. This means that the first NS RR for the "secondary nameserver" has to check if name compression is possible instead of simply referring to the name in the first NS RR. Therefore I've duplicated the logic used with the aforementioned call.

What do you think? And if this was indeed a bug, would it be possible to include my patch upstream or fix the issue in a different way?

Regards,
Thomas (Erbesdobler)


_______________________________________________
Dnsmasq-discuss mailing list
[email protected]
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss