]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolvectl: include ifindex when printing link-local DNS server
authorNick Rosbrook <enr0n@ubuntu.com>
Fri, 6 Feb 2026 16:38:47 +0000 (11:38 -0500)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 6 Feb 2026 23:14:37 +0000 (00:14 +0100)
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

src/resolve/resolvectl.c

index 9f5616c27212670c773cdd7d9f2751778a8ff3a0..8d887b1fcef06421e7e77c822551b96eec227d32 100644 (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)