1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

resolved: when configuring 127.0.0.1 as per-interface DNS server, contact it via "lo" always

ussually if you specify a DNS server on some interface then we'll use
that interface to talk to it. Let's override this for localhost
addresses, as they only really make sense on "lo".

Fixes: #25397
This commit is contained in:
Lennart Poettering 2022-11-18 16:52:06 +01:00
parent 5faaed5b62
commit 6e32414a66

View File

@ -648,6 +648,11 @@ int dns_server_adjust_opt(DnsServer *server, DnsPacket *packet, DnsServerFeature
int dns_server_ifindex(const DnsServer *s) {
assert(s);
/* For loopback addresses, go via the loopback interface, regardless which interface this is linked
* to. */
if (in_addr_is_localhost(s->family, &s->address))
return LOOPBACK_IFINDEX;
/* The link ifindex always takes precedence */
if (s->link)
return s->link->ifindex;