xjasonlyu / tun2socks

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

[Bug] [UDP] dial 8.8.8.8:53: client handshake: EOF #230

Closed qaiwiz closed 1 year ago

qaiwiz commented 1 year ago

Verify steps

Version

tun2socks-2.4.1 darwin/amd64, go1.20.1, 6cfc253

What OS are you seeing the problem on?

macOS

Description

I am trying to setup tun2socks on my macos laptop. I already have a server running at xx.xx.xx.xx

ssh -D 1080 user@xx.xx.xx.xx

then I run tun2socks: sudo tun2socks -device utun123 -proxy socks5://127.0.0.1:1080 -interface en0 sudo ifconfig utun123 198.18.0.1 198.18.0.1 up

followed by sudo route add -net 1.0.0.0/8 198.18.0.1 sudo route add -net 2.0.0.0/7 198.18.0.1 sudo route add -net 4.0.0.0/6 198.18.0.1 sudo route add -net 8.0.0.0/5 198.18.0.1 sudo route add -net 16.0.0.0/4 198.18.0.1 sudo route add -net 32.0.0.0/3 198.18.0.1 sudo route add -net 64.0.0.0/2 198.18.0.1 sudo route add -net 128.0.0.0/1 198.18.0.1 sudo route add -net 198.18.0.0/15 198.18.0.1

Then I get continuous UDP warning: [UDP] dial 8.8.8.8:53: client handshake: EOF

Note 1: on the server I have already used ufw to allow port 53/tcp and 53/udp. Note 2: I have already running stunnel on the server and client too. when I try the above tun2socks with stunnel, I get this error: dial xx.xx.xx.xx:port: read tcp 127.0.0.1:60542->127.0.0.1:1080: read: connection reset by peer where xx.xx.xx.xx:port are specified in the stunnel config. I should mention that I have no problem using stunnel with SSH -D for socks proxy just to ensure that stunnel config and cert is working fine.

Is there anything I can do on the server or client to fix the problem with stunnel or just regular port forwarding?

CLI or Config

No response ... WARN[0082] [UDP] dial 8.8.8.8:53: client handshake: EOF WARN[0083] [UDP] dial 8.8.8.8:53: client handshake: EOF WARN[0085] [UDP] dial 8.8.4.4:53: client handshake: EOF WARN[0085] [UDP] dial 8.8.4.4:53: client handshake: EOF WARN[0085] [UDP] dial 8.8.4.4:53: client handshake: EOF WARN[0085] [UDP] dial 8.8.4.4:53: client handshake: EOF WARN[0085] [UDP] dial 8.8.4.4:53: client handshake: EOF ...

No response

How to Reproduce

No response

xjasonlyu commented 1 year ago

If you’re using SSH as the proxy server, then you should know that it doesn’t support UDP, which causes this error.

qaiwiz commented 1 year ago

uh thanks. Just a couple of questions/comment: 1) I read that socks5 support udp in addition to tcp! I used to be able to answer my voice call using ssh D+stunnel. 2) Do you have any idea how to combine tcp/udp over ssh D+stunnel+tun2socks? (maybe udpgw) 3) What is the most organic communication proxy that can be combined with tun2socks? V2ray, OpenVPN, Wireguard, etc can be detected and throttled.

xjasonlyu commented 1 year ago
  1. right, but not all socks5 servers have UDP supported.
  2. no idea, I personally do not recommend to use SSH as a long-time proxy server.
  3. v2ray, proxy servers only.
qaiwiz commented 1 year ago

there are two drawbacks with v2ray, 1) most contents are in Chinese, 2) in my country it is throttled. I have tried different versions, and most of then get knocked out in less than a week. Only organic traffic can pass through, that is why I use stunnel. I appreciate if you can direct me to a v2ray server installation which could overcome these.

xjasonlyu commented 1 year ago

Sorry for the inconvenience

  1. v2ray has English ver doc: https://www.v2fly.org/en_US/v5/config/overview.html
  2. Try the trojan protocol, it should be a good proxy type in areas with network censorship
qaiwiz commented 1 year ago

thanks. will do.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days