From 1fb84560211b918e5411399f39a1d20431ad21b1 Mon Sep 17 00:00:00 2001 From: eronez <55025357+eronez@users.noreply.github.com> Date: Fri, 13 Feb 2026 03:40:09 +0000 Subject: [PATCH] Fix DNS not revert while close tun --- tun_linux.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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() +}