@@ -72,7 +72,7 @@ func (t *NativeTun) configure() error {
7272 if err != nil {
7373 return E .Cause (err , "set ipv4 address" )
7474 }
75- if ! t .options .EXP_DisableDNSHijack {
75+ if t . options . AutoRoute && ! t .options .EXP_DisableDNSHijack {
7676 dnsServers := common .Filter (t .options .DNSServers , netip .Addr .Is4 )
7777 if len (dnsServers ) == 0 && HasNextAddress (t .options .Inet4Address [0 ], 1 ) {
7878 dnsServers = []netip.Addr {t .options .Inet4Address [0 ].Addr ().Next ()}
@@ -83,14 +83,19 @@ func (t *NativeTun) configure() error {
8383 return E .Cause (err , "set ipv4 dns" )
8484 }
8585 }
86+ } else {
87+ err = luid .SetDNS (winipcfg .AddressFamily (windows .AF_INET ), nil , nil )
88+ if err != nil {
89+ return E .Cause (err , "set ipv4 dns" )
90+ }
8691 }
8792 }
8893 if len (t .options .Inet6Address ) > 0 {
8994 err := luid .SetIPAddressesForFamily (winipcfg .AddressFamily (windows .AF_INET6 ), t .options .Inet6Address )
9095 if err != nil {
9196 return E .Cause (err , "set ipv6 address" )
9297 }
93- if ! t .options .EXP_DisableDNSHijack {
98+ if t . options . AutoRoute && ! t .options .EXP_DisableDNSHijack {
9499 dnsServers := common .Filter (t .options .DNSServers , netip .Addr .Is6 )
95100 if len (dnsServers ) == 0 && HasNextAddress (t .options .Inet6Address [0 ], 1 ) {
96101 dnsServers = []netip.Addr {t .options .Inet6Address [0 ].Addr ().Next ()}
@@ -101,6 +106,11 @@ func (t *NativeTun) configure() error {
101106 return E .Cause (err , "set ipv6 dns" )
102107 }
103108 }
109+ } else {
110+ err = luid .SetDNS (winipcfg .AddressFamily (windows .AF_INET6 ), nil , nil )
111+ if err != nil {
112+ return E .Cause (err , "set ipv6 dns" )
113+ }
104114 }
105115 }
106116 if len (t .options .Inet4Address ) > 0 || len (t .options .Inet6Address ) > 0 {
0 commit comments