resolvectl: include ifindex when printing link-local DNS server

Historically, resolvectl status has not included the interface
specification for DNS servers with an IPv6 link-local address, since it
is technically somewhat redundant. But, adding this extra bit of
information makes it easier to copy-and-paste to use elsewhere, etc.

For example, the previous output:

 Link 2 (enp34s0)
     Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
          Protocols: +DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
 Current DNS Server: fe80::861e:a3ff:feb1:f8e7
        DNS Servers: 192.168.1.12 192.168.1.13 fe80::861e:a3ff:feb1:f8e7
         DNS Domain: lan

now becomes:

 Link 2 (enp34s0)
     Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
          Protocols: +DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
 Current DNS Server: fe80::861e:a3ff:feb1:f8e7%2
        DNS Servers: 192.168.1.12 192.168.1.13 fe80::861e:a3ff:feb1:f8e7%2
         DNS Domain: lan
This commit is contained in:
Nick Rosbrook
2026-02-07 00:14:37 +01:00
committed by Luca Boccassi
parent a53e369786
commit e28958315f
+2 -3
View File
@@ -1584,14 +1584,13 @@ static int varlink_dump_dns_configuration(sd_json_variant **ret) {
}
static int format_dns_server_one(DNSConfiguration *configuration, DNSServer *s, char **ret) {
bool global, with_ifindex;
bool global;
int r;
assert(s);
assert(ret);
global = !(configuration->ifindex > 0 || configuration->delegate);
with_ifindex = configuration->ifindex <= 0;
if (global && s->ifindex > 0 && s->ifindex != LOOPBACK_IFINDEX) {
/* This one has an (non-loopback) ifindex set, and we were told to suppress those. Hence do so. */
@@ -1603,7 +1602,7 @@ static int format_dns_server_one(DNSConfiguration *configuration, DNSServer *s,
s->family,
&s->in_addr,
s->port != 53 ? s->port : 0,
with_ifindex ? s->ifindex : 0,
s->ifindex,
s->server_name,
ret);
if (r < 0)