• 欢迎访问V2ray教程网,这里分享各种V2ray教程资源,为您答题解惑。
  • 任何疑惑,请注册账号后,登录,发布留言,我们会及时回复您。
  • 欢迎加入V2ray电报群,V2ray教程

游戏福音:kcptun+udp2raw解决udp干扰/QoS

大神教程 Teddy 5年前 (2019-12-05) 2979次浏览 0个评论 扫描二维码

        声明:本文仅转载,版权归原作者所有,可能不适合本机场。如果你对 V2Ray 机场 感兴趣,点击这里: V2Ray 机场 在线节点 50+,开放注册!!还便宜!!!

 

自从上了 kcptun,玩这种美服游戏就感觉在玩国服,几乎感觉不到什么延时,然而好景不长。。延时的问题算是解决了,但新的问题粗来了。。

最近这几天经常会出现 kcptun 断流的问题,具体表现是 kcptun 这边不报任何错误,但经过 kcptun 的流量就是无法到达对端,基本上只要断流了就要等个几分钟才能恢复(或者根本恢复不了,就像黑名单了一样)。

最直观的是在 sstap 上测试连接,走了 kcptun 的流量全部连接都被服务器放弃:

游戏福音:kcptun+udp2raw解决udp干扰/QoS

如果这时候直接连接 ss 的话是没有问题的,所以我初步怀疑是电信运营商 QoS 了。

后续我将宽带 IP 重新拨号,只要换一个 IP 就能立马连上,所以基本可以断定是电信这边搞的鬼。

我寻思我就每天拿来玩下游戏,一天下来用的流量也不超过 2GB,你这样搞,简直没有人性啊!TM 的一个月 125 的宽带这点 UDP 流量都不让跑?

没办法,kcptun 这个东西我必须要用,所以只能在 kcptun 前面再套一个 udp2raw 解决运营商的 QoS 问题了。

其实说实话,这样配置起来的话我自己都觉得有点麻烦了,这套那套的。。端口用了一堆,软件也开了一堆。。对于新手来说肯定是极其不友好,所以我建议萌新如果怕麻烦,直接花钱买现成的服务吧。。。(不过买的肯定没这样配置的好用)

首先要准备一堆软件:

<span class="pln">https</span><span class="pun">:</span><span class="com">//github.com/xtaci/kcptun/releases # 服务端和客户端都要下载</span><span class="pln">
https</span><span class="pun">:</span><span class="com">//github.com/dfdragon/kcptun_gclient/releases # 客户端下载</span><span class="pln">
https</span><span class="pun">:</span><span class="com">//github.com/wangyu-/udp2raw-tunnel/releases # 服务端下载</span><span class="pln">
https</span><span class="pun">:</span><span class="com">//github.com/wangyu-/udp2raw-multiplatform/releases # 客户端下载</span><span class="pln">
https</span><span class="pun">:</span><span class="com">//github.com/wangyu-/tinyPortMapper/releases # 客户端下载</span><span class="pln">
https</span><span class="pun">:</span><span class="com">//github.com/mayunbaba2/SSTap-beta-setup # 客户端下载</span>

以下步骤在 Debian10 上完成。其他系统除了 supervisor 的配置文件路径有点变化外基本也一样。

安装 ss 和一些工具:

<span class="pln">apt </span><span class="pun">-</span><span class="pln">y update
apt </span><span class="pun">-</span><span class="pln">y install shadowsocks</span><span class="pun">-</span><span class="pln">libev supervisor wget nano</span>

下载 kcptun:

<span class="pln">mkdir </span><span class="pun">-</span><span class="pln">p </span><span class="pun">/</span><span class="pln">opt</span><span class="pun">/</span><span class="pln">kcptun </span><span class="pun">&&</span><span class="pln"> cd </span><span class="pun">/</span><span class="pln">opt</span><span class="pun">/</span><span class="pln">kcptun
wget https</span><span class="pun">:</span><span class="com">//github.com/xtaci/kcptun/releases/download/v20190924/kcptun-linux-amd64-20190924.tar.gz</span><span class="pln">
tar </span><span class="pun">-</span><span class="pln">xzvf kcptun</span><span class="pun">-</span><span class="pln">linux</span><span class="pun">-</span><span class="pln">amd64</span><span class="pun">-</span><span class="lit">20190924.tar</span><span class="pun">.</span><span class="pln">gz
chmod </span><span class="pun">+</span><span class="pln">x server_linux_amd64</span>

下载 udp2raw:

<span class="pln">mkdir </span><span class="pun">-</span><span class="pln">p </span><span class="pun">/</span><span class="pln">opt</span><span class="pun">/</span><span class="pln">udp2raw </span><span class="pun">&&</span><span class="pln"> cd </span><span class="pun">/</span><span class="pln">opt</span><span class="pun">/</span><span class="pln">udp2raw
wget https</span><span class="pun">:</span><span class="com">//github.com/wangyu-/udp2raw-tunnel/releases/download/20190716.test.0/udp2raw_binaries.tar.gz</span><span class="pln">
tar </span><span class="pun">-</span><span class="pln">xzvf udp2raw_binaries</span><span class="pun">.</span><span class="pln">tar</span><span class="pun">.</span><span class="pln">gz
chmod </span><span class="pun">+</span><span class="pln">x udp2raw_amd64</span>

编辑 ss 的配置文件:

<span class="pln">nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">shadowsocks</span><span class="pun">-</span><span class="pln">libev</span><span class="pun">/</span><span class="pln">config</span><span class="pun">.</span><span class="pln">json</span>

修改为:

<span class="pun">{</span>
    <span class="str">"server"</span><span class="pun">:</span> <span class="str">"0.0.0.0"</span><span class="pun">,</span>
    <span class="str">"mode"</span><span class="pun">:</span><span class="str">"tcp_and_udp"</span><span class="pun">,</span>
    <span class="str">"server_port"</span><span class="pun">:</span><span class="lit">12315</span><span class="pun">,</span>
    <span class="str">"local_port"</span><span class="pun">:</span><span class="lit">1080</span><span class="pun">,</span>
    <span class="str">"password"</span><span class="pun">:</span><span class="str">"设置你的 ss 密码"</span><span class="pun">,</span>
    <span class="str">"timeout"</span><span class="pun">:</span><span class="lit">60</span><span class="pun">,</span>
    <span class="str">"method"</span><span class="pun">:</span><span class="str">"chacha20-ietf-poly1305"</span>
<span class="pun">}</span>

重启 ss 以及设置 ss 开机自启:

<span class="pln">systemctl restart shadowsocks</span><span class="pun">-</span><span class="pln">libev
systemctl enable shadowsocks</span><span class="pun">-</span><span class="pln">libev</span>

新建 kcptun 配置文件:

<span class="pln">nano </span><span class="pun">/</span><span class="pln">opt</span><span class="pun">/</span><span class="pln">kcptun</span><span class="pun">/</span><span class="pln">server</span><span class="pun">-</span><span class="pln">config</span><span class="pun">.</span><span class="pln">json</span>

写入如下配置(MTU 设置为 1300 或者更小):

<span class="pun">{</span>
<span class="str">"listen"</span><span class="pun">:</span> <span class="str">":30000"</span><span class="pun">,</span>
<span class="str">"target"</span><span class="pun">:</span> <span class="str">"127.0.0.1:12315"</span><span class="pun">,</span>
<span class="str">"key"</span><span class="pun">:</span> <span class="str">"设置一个密码"</span><span class="pun">,</span>
<span class="str">"crypt"</span><span class="pun">:</span> <span class="str">"salsa20"</span><span class="pun">,</span>
<span class="str">"mode"</span><span class="pun">:</span> <span class="str">"fast3"</span><span class="pun">,</span>
<span class="str">"mtu"</span><span class="pun">:</span> <span class="lit">1300</span><span class="pun">,</span>
<span class="str">"sndwnd"</span><span class="pun">:</span> <span class="lit">1024</span><span class="pun">,</span>
<span class="str">"rcvwnd"</span><span class="pun">:</span> <span class="lit">1024</span><span class="pun">,</span>
<span class="str">"datashard"</span><span class="pun">:</span> <span class="lit">2</span><span class="pun">,</span>
<span class="str">"parityshard"</span><span class="pun">:</span> <span class="lit">2</span><span class="pun">,</span>
<span class="str">"dscp"</span><span class="pun">:</span> <span class="lit">46</span><span class="pun">,</span>
<span class="str">"nocomp"</span><span class="pun">:</span> <span class="kwd">true</span>
<span class="pun">}</span>

注:这套是游戏加速的配置,如果是看 Youtube 视频等大流量应用,需要把 datashard 以及 parityshard 适当增大。

新建一个 kcptun 的 supervisor 配置文件:

<span class="pln">nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">supervisor</span><span class="pun">/</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">kcptun</span><span class="pun">.</span><span class="pln">conf</span>

写入:

<span class="pun">[</span><span class="pln">program</span><span class="pun">:</span><span class="pln">kcptun</span><span class="pun">]</span><span class="pln">
priority</span><span class="pun">=</span><span class="lit">1</span><span class="pln">
directory</span><span class="pun">=</span><span class="str">/opt/</span><span class="pln">kcptun
command</span><span class="pun">=</span><span class="str">/opt/</span><span class="pln">kcptun</span><span class="pun">/</span><span class="pln">server_linux_amd64 </span><span class="pun">-</span><span class="pln">c </span><span class="pun">/</span><span class="pln">opt</span><span class="pun">/</span><span class="pln">kcptun</span><span class="pun">/</span><span class="pln">server</span><span class="pun">-</span><span class="pln">config</span><span class="pun">.</span><span class="pln">json
autostart</span><span class="pun">=</span><span class="kwd">true</span><span class="pln">
autorestart</span><span class="pun">=</span><span class="kwd">true</span><span class="pln">
redirect_stderr</span><span class="pun">=</span><span class="kwd">true</span><span class="pln">
stdout_logfile</span><span class="pun">=</span><span class="str">/var/</span><span class="pln">log</span><span class="pun">/</span><span class="pln">supervisor</span><span class="pun">/</span><span class="pln">kcptun</span><span class="pun">.</span><span class="pln">log</span>

再新建一个 udp2raw 的 supervisor 配置文件:

<span class="pln">nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">supervisor</span><span class="pun">/</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">udp2raw</span><span class="pun">.</span><span class="pln">conf</span>

写入如下配置:

<span class="pun">[</span><span class="pln">program</span><span class="pun">:</span><span class="pln">udp2raw</span><span class="pun">]</span><span class="pln">
user</span><span class="pun">=</span><span class="pln">root
priority</span><span class="pun">=</span><span class="lit">1</span><span class="pln">
directory</span><span class="pun">=</span><span class="str">/opt/</span><span class="pln">udp2raw
command</span><span class="pun">=</span><span class="str">/opt/</span><span class="pln">udp2raw</span><span class="pun">/</span><span class="pln">udp2raw_amd64 </span><span class="pun">-</span><span class="pln">s </span><span class="pun">-</span><span class="pln">l </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">30001</span> <span class="pun">-</span><span class="pln">r </span><span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span><span class="pun">:</span><span class="lit">30000</span> <span class="pun">--</span><span class="pln">raw</span><span class="pun">-</span><span class="pln">mode faketcp </span><span class="pun">-</span><span class="pln">a </span><span class="pun">-</span><span class="pln">k </span><span class="str">"设置一个你的密码"</span><span class="pln">
autostart</span><span class="pun">=</span><span class="kwd">true</span><span class="pln">
autorestart</span><span class="pun">=</span><span class="kwd">true</span><span class="pln">
redirect_stderr</span><span class="pun">=</span><span class="kwd">true</span><span class="pln">
stdout_logfile</span><span class="pun">=</span><span class="str">/var/</span><span class="pln">log</span><span class="pun">/</span><span class="pln">supervisor</span><span class="pun">/</span><span class="pln">udp2raw</span><span class="pun">.</span><span class="pln">log</span>

更新 supervisor 配置/开机自启:

<span class="pln">supervisorctl update
systemctl enable supervisor</span>

服务端这边的配置就完成了,接下来是客户端的。

首先用管理员权限开 2 个 powershell,进入到软件的根目录:

<span class="pln">cd C</span><span class="pun">:</span><span class="pln">\Users\LALA\Desktop\udp</span>

第一个 powershell 运行 tinyPortMapper 用来转发 UDP 流量:

<span class="pun">.</span><span class="pln">\tinymapper_wepoll</span><span class="pun">.</span><span class="pln">exe </span><span class="pun">-</span><span class="pln">l </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">9527</span> <span class="pun">-</span><span class="pln">r VPS</span><span class="pun">公网</span><span class="pln">IP</span><span class="pun">:</span><span class="lit">12315</span> <span class="pun">-</span><span class="pln">u</span>

这步的作用仅仅只是为了让 SSTap 能够测试通过 UDP 转发,让其能够可以连接代理服务器,对于使用 TCP 协议进行连接的游戏而言这个操作没有实际意义。

第二个 powershell 运行 udp2raw 的 windows 客户端:

<span class="pun">.</span><span class="pln">\udp2raw_mp_nolibnet</span><span class="pun">.</span><span class="pln">exe </span><span class="pun">-</span><span class="pln">c </span><span class="pun">-</span><span class="pln">r VPS</span><span class="pun">公网</span><span class="pln">IP</span><span class="pun">:</span><span class="lit">30001</span> <span class="pun">-</span><span class="pln">l </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">:</span><span class="lit">5000</span> <span class="pun">--</span><span class="pln">raw</span><span class="pun">-</span><span class="pln">mode easyfaketcp </span><span class="pun">-</span><span class="pln">k </span><span class="str">"对应服务端上的 udp2raw 密码"</span>

打开 KCP 客户端配置管理工具,新建一个客户端,按照下图配置:

游戏福音:kcptun+udp2raw解决udp干扰/QoS

传输模式和服务端上的配置对应这里选择 fast3:

游戏福音:kcptun+udp2raw解决udp干扰/QoS

现在打开 SSTap 添加一个 ss 代理,配置如下:

游戏福音:kcptun+udp2raw解决udp干扰/QoS

最后点击 SSTap 的齿轮按钮,打开附加路由管理,在里面添加上你的 VPS 公网 IP,动作选择直连:

游戏福音:kcptun+udp2raw解决udp干扰/QoS

没问题的话现在连上应该就 OK 了。

一点后续补充:

在本地每次都要开两个 powershell 感觉不优雅?这里其实可以用 winSW 把这两个命令行工具创建成 windows 服务,这样就能开机自启而且还不需要 powershell 了,具体的 winSW 用法,可以看这里,我实在没时间码字了,告辞:

https://github.com/kohsuke/winsw/blob/master/doc/installation.md


V2ray教程网 版权所有丨如未注明 , 均为原创丨转载请注明原文链接:游戏福音:kcptun+udp2raw解决udp干扰/QoS
喜欢 (0)

您必须 登录 才能发表评论!