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