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

[Bug] No connection with Google cloud VPS #363

Open Vicio59 opened 1 month ago

Vicio59 commented 1 month ago

Verify steps

Version

latest

What OS are you seeing the problem on?

Linux

Description

Hi, I've been using tun2socks for over a year now and it has never given me any problems. Since I purchased a Google Cloud VPS with debian (where I installed docker and then tun2socks) the connection doesn't work, I tried add google DNS on /etc/resolv.conf file, i tried wget to see if the problem was DNS resolution but even with a IP (example 1.1.1.1) I don't receive anything.

docker exec -it tun2socks5 /bin/sh / # wget -qO- ifconfig.me/ip wget: bad address 'ifconfig.me' / # wget -qO- 1.1.1.1 wget: error getting response: Connection reset by peer

The proxy server works because with other VPS like AWS or Kamatera I can make tun2socks work without problems. The proxy server supports udp among other things. Any suggestions are welcome, thanks

CLI or Config

sudo docker run --name tun2socks --restart=always -e LOGLEVEL=info -e PROXY=socks5://MYUSER:MYPASS@IPPROXYSERVER:1080 -v '/dev/net/tun:/dev/net/tun' --cap-add=NET_ADMIN -d xjasonlyu/tun2socks:latest

Logs

No response

How to Reproduce

No response

xjasonlyu commented 1 month ago

Can you test with curl -v 1.1.1.1 for example to see if your tun2socks container works with tcp/http request first?

Vicio59 commented 1 month ago

sudo docker run --name curl --network=container:tun2socks5 curlimages/curl -v 1.1.1.1 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 1.1.1.1:80...

xjasonlyu commented 1 month ago

yea, looks like it's not a DNS issue.

Vicio59 commented 1 month ago

What could it be? It's the first time I've had a problem with tun2socks, it doesn't seem to work only with Google Cloud VPS, thanks

xjasonlyu commented 1 month ago

Did you try to bind it to a correct interface?

Vicio59 commented 1 month ago

In what sense? if I run ifconfig inside the tun2socks container the only interfaces I see are: eth0, lo and tun0. Do you mean if I manually bound the container tun2socks to eth0?

xjasonlyu commented 1 month ago

Can you confirm your proxy works inside the tun2socks container?

Vicio59 commented 1 month ago

Do you mean if I tested my proxy by running curl inside the tun2socks container? No, I couldn't do it because curl is not installed inside the tun2socks container, I tried with wget -qO- 1.1.1.1 and failed

xjasonlyu commented 1 month ago

Do you mean if I tested my proxy by running curl inside the tun2socks container? No, I couldn't do it because curl is not installed inside the tun2socks container, I tried with wget -qO- 1.1.1.1 and failed

I mean you can install that by running apk install curl, but you'll probably wanna turn off tun2socks process first or so.

Vicio59 commented 1 month ago

Ok, I managed to install curl on the tun2socks container but previously it still didn't work even with curl 1.1.1.1. After playing with the ip rule and ip route rules it seems like it now works with tcp/http requests because curl 1.1.1.1 works, but dns doesn't work. These are my rules and the tests I did:


/ # ip rule
0:      from all lookup local
9:      from all iif lo ipproto udp dport 53 lookup main
10:     from all to MYSERVERIP lookup main
20:     from all lookup 20
32766:  from all lookup main
32767:  from all lookup default
/ # ip route
default via 172.17.0.1 dev eth0
198.18.0.0/15 dev tun0 proto kernel scope link src 198.18.0.1

/ # curl --interface tun0 ifconfig.me
curl: (6) Could not resolve host: ifconfig.me

/ # curl --interface tun0 1.1.1.1
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>cloudflare</center>
</body>
</html>

/ # curl 1.1.1.1
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>cloudflare</center>
</body>
</html>

What could be the problem in your opinion?

xjasonlyu commented 1 month ago

No, I mean you can try something like curl -v 1.1.1.1 -x "socks5://your-proxy" --interface eth0 to see if your proxy works inside the container.

Vicio59 commented 1 month ago

ok, I tried with:

/ # curl -v 1.1.1.1 --proxy socks5://MYUSER:MYPASS@SERVERIP:PORT --interface eth0

After which it stops like this, while I tried the same command directly on the server and it works