Skip to content

Commit 406135b

Browse files
authored
Fix DNS issue in TUN mode (#824)
1 parent c55a5f6 commit 406135b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Netch/Controllers/TUNController.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public async Task StartAsync(Socks5Server server, Mode mode)
9393

9494
if (_tunConfig.UseCustomDNS)
9595
{
96-
Dial(NameList.TYPE_DNSADDR, _tunConfig.DNS);
96+
Dial(NameList.TYPE_DNSADDR, DnsUtils.AppendPort(_tunConfig.DNS));
9797
}
9898
else
9999
{
@@ -175,8 +175,13 @@ private void SetupRouteTable()
175175

176176
if (_tunConfig.UseCustomDNS)
177177
{
178-
// NOTICE: DNS metric is network interface metric
179-
RouteUtils.CreateRoute(_tun.FillTemplate(_tunConfig.DNS, 32));
178+
if (_tunConfig.ProxyDNS)
179+
{
180+
// NOTICE: DNS metric is network interface metric
181+
RouteUtils.CreateRoute(_tun.FillTemplate(_tunConfig.DNS, 32));
182+
}
183+
184+
tunNetworkInterface.SetDns(_tunConfig.DNS);
180185
}
181186
else
182187
{

0 commit comments

Comments
 (0)