From 163c8c75c627af89ce1e37bc07c7ae0cbe2ca5dd 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 013132b..3d6762d 100644 --- a/cmd/cli/os_linux.go +++ b/cmd/cli/os_linux.go @@ -80,7 +80,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") }