|
|
ac3a84 |
From d8d96bce62e8597b8d35bed1d9e9cb103336fd6b Mon Sep 17 00:00:00 2001
|
|
|
ac3a84 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
ac3a84 |
Date: Fri, 18 Nov 2022 16:52:06 +0100
|
|
|
ac3a84 |
Subject: [PATCH] resolved: when configuring 127.0.0.1 as per-interface DNS
|
|
|
ac3a84 |
server, contact it via "lo" always
|
|
|
ac3a84 |
|
|
|
ac3a84 |
ussually if you specify a DNS server on some interface then we'll use
|
|
|
ac3a84 |
that interface to talk to it. Let's override this for localhost
|
|
|
ac3a84 |
addresses, as they only really make sense on "lo".
|
|
|
ac3a84 |
|
|
|
ac3a84 |
Fixes: #25397
|
|
|
ac3a84 |
(cherry picked from commit 6e32414a66ff8dbcef233981a7066684d903ee9f)
|
|
|
ac3a84 |
|
|
|
ac3a84 |
Related: #2138081
|
|
|
ac3a84 |
---
|
|
|
ac3a84 |
src/resolve/resolved-dns-server.c | 5 +++++
|
|
|
ac3a84 |
1 file changed, 5 insertions(+)
|
|
|
ac3a84 |
|
|
|
ac3a84 |
diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c
|
|
|
ac3a84 |
index 04a4f53ed0..8ff513fa33 100644
|
|
|
ac3a84 |
--- a/src/resolve/resolved-dns-server.c
|
|
|
ac3a84 |
+++ b/src/resolve/resolved-dns-server.c
|
|
|
ac3a84 |
@@ -648,6 +648,11 @@ int dns_server_adjust_opt(DnsServer *server, DnsPacket *packet, DnsServerFeature
|
|
|
ac3a84 |
int dns_server_ifindex(const DnsServer *s) {
|
|
|
ac3a84 |
assert(s);
|
|
|
ac3a84 |
|
|
|
ac3a84 |
+ /* For loopback addresses, go via the loopback interface, regardless which interface this is linked
|
|
|
ac3a84 |
+ * to. */
|
|
|
ac3a84 |
+ if (in_addr_is_localhost(s->family, &s->address))
|
|
|
ac3a84 |
+ return LOOPBACK_IFINDEX;
|
|
|
ac3a84 |
+
|
|
|
ac3a84 |
/* The link ifindex always takes precedence */
|
|
|
ac3a84 |
if (s->link)
|
|
|
ac3a84 |
return s->link->ifindex;
|