cmd/cli: only save/restore static DNS

The save/restore DNS functionality always perform its job, even though
the DNS is not static, aka set by DHCP. That may lead to confusion to
users. Since DHCP settings was changed to static settings, even though
the namesers set are the same.

To fix this, ctrld should save/restore only there's actual static DNS
set. For DHCP, thing should work as-is like we are doing.
This commit is contained in:
Cuong Manh Le
2024-02-09 12:35:43 +07:00
committed by Cuong Manh Le
parent 18e8616834
commit 4d810261a4
6 changed files with 122 additions and 26 deletions
+5
View File
@@ -203,6 +203,11 @@ func currentDNS(iface *net.Interface) []string {
return nil
}
// currentStaticDNS returns the current static DNS settings of given interface.
func currentStaticDNS(iface *net.Interface) []string {
return currentDNS(iface)
}
func getDNSByResolvectl(iface string) []string {
b, err := exec.Command("resolvectl", "dns", "-i", iface).Output()
if err != nil {