From 0438aa57751559295fee86d1c1f176486e518455 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 22 Jun 2023 22:26:23 +0200 Subject: [PATCH] =?utf8?q?resolved:=20if=20ipv6=20is=20off=20patch=20hostn?= =?utf8?q?ame=E2=86=92address=20query=20with=20unspec=20family=20to=20ipv4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If the client never specified the address family, and IPv6 is off in the kernel, then look only for A, never for AAAA RRs. Fixes: #23951 --- src/resolve/resolved-dns-question.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/resolve/resolved-dns-question.c b/src/resolve/resolved-dns-question.c index 8f5ebb4590d..5754c851117 100644 --- a/src/resolve/resolved-dns-question.c +++ b/src/resolve/resolved-dns-question.c @@ -4,6 +4,7 @@ #include "dns-domain.h" #include "dns-type.h" #include "resolved-dns-question.h" +#include "socket-util.h" DnsQuestion *dns_question_new(size_t n) { DnsQuestion *q; @@ -330,6 +331,11 @@ int dns_question_new_address(DnsQuestion **ret, int family, const char *name, bo if (!IN_SET(family, AF_INET, AF_INET6, AF_UNSPEC)) return -EAFNOSUPPORT; + /* If IPv6 is off and the request has an unspecified lookup family, restrict it automatically to + * IPv4. */ + if (family == AF_UNSPEC && !socket_ipv6_is_enabled()) + family = AF_INET; + if (convert_idna) { r = dns_name_apply_idna(name, &buf); if (r < 0) -- 2.47.3