eycorsican / go-tun2socks

A tun2socks implementation written in Go.
MIT License
1.3k stars 432 forks source link

Windows下启动没有网关? #24

Closed thanksshu closed 5 years ago

thanksshu commented 5 years ago

打算用这个加速游戏,下载1.9.0版本、用Tap-windows-9.22.1-I602创建网卡,根据README里的介绍: tun2socks -tunName tun1 -tunAddr 10.0.0.2 -tunGw 10.0.0.1 -proxyType socks -proxyServer 127.0.0.1:1082 1082端口是SSR的代理入口、可用, 启动后查看网络信息默认网关项为空而且Ping不通,请问如何解决呢? 另外想问一下像这样代理服务器在本地的情况下,该如何配置路由表和其他选项呢?

感谢作者!

eycorsican commented 5 years ago

你可以在输出信息看到用哪个网卡,你可以手动设置下网卡的地址信息,路由那边设置换成你SSR服务器的地址

thanksshu commented 5 years ago

@eycorsican 谢谢! 但是像这样设置好了网卡后用原先的脚本启动,依旧没有解决网关不存在的问题: default ifconfig网卡内容: default tun2socks.exe 进程: default 貌似tun2socks.exe在启动的时候会覆盖原先的参数,比如图片里的DNS项? 所以先启动了网卡再尝试修改参数……并没有作用。

eycorsican commented 5 years ago

对的,正常来说启动时找到虚拟网卡后配置上地址信息,看起来启动没问题,但流量没转给虚拟网卡上,你没配置好默认路由吧?

route add 0.0.0.0 mask 0.0.0.0 10.0.0.1 metric 6

thanksshu commented 5 years ago

@eycorsican 的确是没有设置路由的……但是提前Ping了网关,发现并不通。

eycorsican commented 5 years ago

你这里的网关是指哪个网关?TUN的?原来网络的?

thanksshu commented 5 years ago

TUN网卡网关(10.0.0.1) 是不通的,TUN网卡地址(10.0.0.2)可以、原网卡网关(192.168.2.1)和地址都可以。

eycorsican commented 5 years ago

好像正常啊,根本不需要有那网关,你继续把路由配好就行

thanksshu commented 5 years ago

这次没再纠结以上问题,

  1. 乖乖启动网卡:

tun2socks.exe -tunName tun1 -tunAddr 10.0.0.2 -tunGw 10.0.0.1 -proxyType socks -proxyServer 127.0.0.1:1081

  1. 配置路由:
route add 0.0.0.0 mask 0.0.0.0 10.0.0.1 metric 6 
route add *.*.*.* 192.168.2.1 metric 5  //代理IP
route delete 0.0.0.0 mask 0.0.0.0 192.168.2.1 metric 100  //删除了默认路由
  1. 然后在本地启动了一个v2ray进程,入口是127.0.0.1:1081,出口是...(已保证可用)

这次路由表也争气多了: 活动路由:

网络目标 网络掩码 网关 接口 跃点数
0.0.0.0 0.0.0.0 10.0.0.1 10.0.0.2 7
10.0.0.0 255.255.255.0 在链路上 10.0.0.2 257
10.0.0.2 255.255.255.255 在链路上 10.0.0.2 257
10.0.0.255 255.255.255.255 在链路上 10.0.0.2 257
... 255.255.255.255 192.168.2.1 192.168.2.101 105
127.0.0.0 255.0.0.0 在链路上 127.0.0.1 306
127.0.0.1 255.255.255.255 在链路上 127.0.0.1 306
127.255.255.255 255.255.255.255 在链路上 127.0.0.1 306
169.254.0.0 255.255.0.0 在链路上 169.254.38.98 266
169.254.38.98 255.255.255.255 在链路上 169.254.38.98 266
169.254.255.255 255.255.255.255 在链路上 169.254.38.98 266
192.168.2.0 255.255.255.0 在链路上 192.168.2.101 356
192.168.2.101 255.255.255.255 在链路上 192.168.2.101 356
192.168.2.255 255.255.255.255 在链路上 192.168.2.101 356
224.0.0.0 240.0.0.0 在链路上 127.0.0.1 306
224.0.0.0 240.0.0.0 在链路上 192.168.2.101 356
224.0.0.0 240.0.0.0 在链路上 169.254.38.98 266
224.0.0.0 240.0.0.0 在链路上 10.0.0.2 257
255.255.255.255 255.255.255.255 在链路上 127.0.0.1 306
255.255.255.255 255.255.255.255 在链路上 192.168.2.101 356
255.255.255.255 255.255.255.255 在链路上 169.254.38.98 266
255.255.255.255 255.255.255.255 在链路上 10.0.0.2 257

(MD表格好麻烦) 这次Tap网关(10.0.0.1)正常访问是没问题的,

然后尝试访问google,结果是无法解析主机……

eycorsican commented 5 years ago

日志呢?

thanksshu commented 5 years ago

感谢提醒,检查日志后发现代理服务器状态不稳定,修复了一下就好了。 谢谢帮助!