From 091c7edb192fbc7db3300842aac96a15290cb5bc Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 21 Oct 2025 17:27:09 +0700 Subject: [PATCH] Fix: Filter root domain from search domains on Linux Remove empty and root domain (".") entries from search domains list to prevent systemd-resolved errors. This addresses the issue where systemd doesn't allow root domain in search domains configuration. The filtering ensures only valid search domains are passed to systemd-resolved, preventing DNS operation failures. --- cmd/cli/os_linux.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/cli/os_linux.go b/cmd/cli/os_linux.go index 8caad63..12f8d43 100644 --- a/cmd/cli/os_linux.go +++ b/cmd/cli/os_linux.go @@ -72,7 +72,15 @@ func setDNS(iface *net.Interface, nameservers []string) error { SearchDomains: []dnsname.FQDN{}, } if sds, err := searchDomains(); err == nil { - osConfig.SearchDomains = sds + // Filter the root domain, since it's not allowed by systemd. + // See https://github.com/systemd/systemd/issues/9515 + filteredSds := slices.DeleteFunc(sds, func(s dnsname.FQDN) bool { + return s == "" || s == "." + }) + if len(filteredSds) != len(sds) { + mainLog.Load().Debug().Msg(`Removed root domain "." from search domains list`) + } + osConfig.SearchDomains = filteredSds } else { mainLog.Load().Debug().Err(err).Msg("failed to get search domains list") }