xjasonlyu / tun2socks

tun2socks - powered by gVisor TCP/IP stack
https://github.com/xjasonlyu/tun2socks/wiki
GNU General Public License v3.0
2.84k stars 403 forks source link

[Feature] Support dns please #367

Open anasfanani opened 2 weeks ago

anasfanani commented 2 weeks ago

Description

When using curl with socks5

curl router-openwrt.xxx.ts.net -v -I -x 127.0.0.1:1099
*   Trying 127.0.0.1:1099...
* Connected to 127.0.0.1 (127.0.0.1) port 1099
> HEAD http://router-openwrt.xxx.ts.net/ HTTP/1.1
> Host: router-openwrt.xxx.ts.net
> User-Agent: curl/8.8.0
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
* Request completely sent off
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Length: 780
Content-Length: 780
< Content-Type: text/html
Content-Type: text/html
< Date: Thu, 06 Jun 2024 08:41:49 GMT
Date: Thu, 06 Jun 2024 08:41:49 GMT
< Etag: "2db0-30c-6531a3aa"
Etag: "2db0-30c-6531a3aa"
< Last-Modified: Thu, 19 Oct 2023 21:46:18 GMT
Last-Modified: Thu, 19 Oct 2023 21:46:18 GMT
< 

After route everything dns can't routed via socks server.

┌──(spesn@localhost)-[~]
└─$ curl router-openwrt.coin-tet.ts.net -v -I
* Could not resolve host: router-openwrt.coin-tet.ts.net
* Closing connection
curl: (6) Could not resolve host: router-openwrt.coin-tet.ts.net
┌──(spesn@localhost)-[~]
└─$ curl router-openwrt.coin-tet.ts.net -v -I --interface tun0
* Could not resolve host: router-openwrt.coin-tet.ts.net
* Closing connection
curl: (6) Could not resolve host: router-openwrt.coin-tet.ts.net
┌──(spesn@localhost)-[~]
└─$ 

Dns server is inside socks proxy.

Is this feature related to a specific bug?

No response

Do you have a specific solution in mind?

No response

mehranmd commented 2 weeks ago

Same here, have a v2ray 5.16.1 running my proxy in the background and tun2socks step by step from toturial on debian.

i get output:

INFO[0003] [UDP] 198.18.0.1:57248 <-> 8.8.8.8:53 INFO[0008] [UDP] 198.18.0.1:47198 <-> 1.1.1.1:53

and dns resolution failure.

ping: google.com: Temporary failure in name resolution curl: (6) Could not resolve host: ifconfig.me

v2ray output:

V2Ray 5.16.1 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.22.2 linux/arm) A unified platform for anti-censorship. 2024/06/07 10:53:28 [Warning] V2Ray 5.16.1 started 2024/06/07 10:53:46 udp:127.0.0.1:36388 accepted udp:8.8.8.8:53 [dns-out] 2024/06/07 10:53:50 udp:127.0.0.1:40142 accepted udp:8.8.8.8:53 [dns-out]

Update: I got a chance to review every doc available for this tool, looks like we have to do some routing in order to make dns work properly:

https://github.com/xjasonlyu/tun2socks/wiki/DNS-Configuration

anasfanani commented 2 weeks ago

Yes dns will work if we make redirection on port 53 to use dns 8.8.8.8

My problem the dns is behind proxy.