diff --git a/tun_linux.go b/tun_linux.go index ac36af2..06c4f92 100644 --- a/tun_linux.go +++ b/tun_linux.go @@ -328,6 +328,7 @@ func (t *NativeTun) Close() error { if t.options.EXP_ExternalConfiguration { return common.Close(common.PtrOrNil(t.tunFile)) } + t.unsetSearchDomainForSystemdResolved() t.unsetAddresses() return E.Errors(t.unsetRoute(), t.unsetRules(), common.Close(common.PtrOrNil(t.tunFile))) } @@ -1094,3 +1095,14 @@ func (t *NativeTun) setSearchDomainForSystemdResolved() { _ = shell.Exec(ctlPath, append([]string{"dns", t.options.Name}, common.Map(dnsServer, netip.Addr.String)...)...).Run() }() } + +func (t *NativeTun) unsetSearchDomainForSystemdResolved() { + if t.options.EXP_DisableDNSHijack { + return + } + ctlPath, err := exec.LookPath("resolvectl") + if err != nil { + return + } + _ = shell.Exec(ctlPath, "revert", t.options.Name).Run() +}