xjasonlyu / tun2socks

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

Proper example on Windows 10 #59

Closed NN-Binary closed 3 years ago

NN-Binary commented 3 years ago

Hi,

I'm having a very hard time as I can't find any concrete example on the route, all the example I find online are for another version of tun2socks.

I just want a concrete example on how to redirect all the traffic to a SOCKS5 proxy (on Windows - Im in a Virtualbox but I don't think it matters), I'm not a network expert and I can't figure out since yesterday.

Please someone help, a step-by-step would be awesome, running tun2socks is no problem but finding out the proper routes I can't find

xjasonlyu commented 3 years ago

It generally requires two steps to setup routes in windows.

  1. make tun2socks interface ip as your default (0.0.0.0) route
  2. exclude your_socks_server_ip to original gateway
NN-Binary commented 3 years ago

Thanks for the help, yeah my problem is finding the exact routes command to also exclude the DNS I just can't find (on Windows), I've tried hundred of route add, netsh....

On your point 1, I don't even know how to properly do that so probably all the next steps are screw-up. Do I start with route add 0.0.0.0 mask 0.0.0.0 10.0.0.2 metric 0?

I'm also confused on 1 point, do I need to create a TUN adapter before executing tun2socks or is it tun2socks taking care of it itself?

Example in this page: Route configuration (https://github.com/xjasonlyu/tun2socks/wiki/Route-configuration) I can't seem to know exactly what those mean:

netsh routing ip add persistentroute

network_address is the address of the TUN adapter?

bb33bb commented 3 years ago

open your ssr ,then socks5://127.0.0.1:1080 is prepaired OK makesure to make your ssr close Load balancing x.x.x.x is your remote server ip y.y.y.y is your local gateway

start cmd /k tun2socks-windows-amd64.exe -device tun://tun00 -proxy socks5://127.0.0.1:1080
netsh interface ip set address "tun00" static address=10.10.10.2 mask=255.255.255.0 gateway=10.10.10.1
netsh interface ip set dns name="tun00" static 8.8.8.8
route add x.x.x.x y.y.y.y metric 5
route add 0.0.0.0 mask 0.0.0.0 10.10.10.1

wsl下git clone速度不理想,不知为何

goldenduo commented 3 years ago

WIN10: Fail to start tun2socks

tun2socks.exe -device tun://wintun0 -proxy socks5://127.0.0.1:1080
2021/08/23 14:34:21 [Wintun] WintunCreateAdapter: Creating adapter
2021/08/23 14:34:21 [Wintun] SelectDriver: Using existing driver 0.13
2021/08/23 14:34:31 [Wintun] RegistryQueryStringWait: Timeout waiting for registry value \REGISTRY\MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0022\NetCfgInstanceId (status: 0x102)
2021/08/23 14:34:31 [Wintun] WintunCreateAdapter: Failed to get \REGISTRY\MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0022\NetCfgInstanceId
time="2021-08-23T14:34:31+08:00" level=fatal msg="Failed to start engine: create tun: Error creating interface: The system cannot find the file specified."
xjasonlyu commented 3 years ago

tun://wintun0 -proxy socks5://127.0.0.1:1080

Try to reset your adapters something.

github-actions[bot] commented 3 years 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

sonvirgo commented 1 year ago

open your ssr ,then socks5://127.0.0.1:1080 is prepaired OK makesure to make your ssr close Load balancing x.x.x.x is your remote server ip y.y.y.y is your local gateway

start cmd /k tun2socks-windows-amd64.exe -device tun://tun00 -proxy socks5://127.0.0.1:1080
netsh interface ip set address "tun00" static address=10.10.10.2 mask=255.255.255.0 gateway=10.10.10.1
netsh interface ip set dns name="tun00" static 8.8.8.8
route add x.x.x.x y.y.y.y metric 5
route add 0.0.0.0 mask 0.0.0.0 10.10.10.1

wsl下git clone速度不理想,不知为何

WIN10: Fail to start tun2socks

tun2socks.exe -device tun://wintun0 -proxy socks5://127.0.0.1:1080
2021/08/23 14:34:21 [Wintun] WintunCreateAdapter: Creating adapter
2021/08/23 14:34:21 [Wintun] SelectDriver: Using existing driver 0.13
2021/08/23 14:34:31 [Wintun] RegistryQueryStringWait: Timeout waiting for registry value \REGISTRY\MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0022\NetCfgInstanceId (status: 0x102)
2021/08/23 14:34:31 [Wintun] WintunCreateAdapter: Failed to get \REGISTRY\MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0022\NetCfgInstanceId
time="2021-08-23T14:34:31+08:00" level=fatal msg="Failed to start engine: create tun: Error creating interface: The system cannot find the file specified."

Using 127.0.0.1 socks, require policy based routing As of now only Linux works See my solution below tun2socks -> localhost cause loop hole, which stop 127.0.0.1 socks server to functioning. Depend on the socks server implementation, but usually socks port not open if a stream is not established See my solution for example Psiphon 127.0.0.1 socks Only work on Linux, support iptables user id range policy, or cgroup. tun2socks-127.0.0.1-loopback``