使用Kcptun+socks5代理,速度杠杠的

需要有一个境外的VPS(Ubuntu 18.04):

1、 安装 danted 启动socks5服务

apt install dante-server
mv /etc/danted.conf /etc/danted.conf.bak

useradd admin
passwd admin

touch /etc/danted.conf
vim /etc/danted.conf

然后写入下面配置,:wq 保存退出,这里我将我的外网地址改成了xxx.xxx.xxx.xxx,需要改成自己的外网IP地址:

logoutput: /var/log/danted.log
internal: 127.0.0.1 port = 19900
external: xxx.xxx.xxx.xxx
method: username
user.privileged: root
user.notprivileged: admin
user.libwrap: nobody
client pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    log: connect disconnect
}
pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    command: bind connect udpassociate
    log: error
    method: username
}
block {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    log: connect error
}

然后启动Socks5服务:

root@bwh88:~/kcptun/build# /etc/init.d/danted start
[ ok ] Starting danted (via systemctl): danted.service.

检查下是否启动成功:

root@bwh88:~/kcptun/build# netstat -antup|grep 19900
tcp        0      0 127.0.0.1:19900         0.0.0.0:*               LISTEN      32529/danted 

SOCK5装好了,还需要装一个kcptun:

apt install git -y && git clone https://github.com/xtaci/kcptun.git
cd kcptun
./build-release.sh

默认生成到build目录下,等待编译完成后,创建服务器端的配置文件:

touch server.json
vim server.json

写入下面配置内容:


{
    "listen": ":19901",
    "target": "127.0.0.1:19900",
    "mode": "fast3",
    "nocomp": true,
    "sockbuf": 16777217,
    "dscp": 46
}

最后在服务器端运行(可以写成系统服务):

/root/kcptun/build/server_linux_amd64 -c /root/kcptun/build/server.json

系统服务(kcptun.service)可以这样写:

Description=kcptun

Wants=network.target
After=syslog.target network-online.target

[Service]
Type=simple
Environment=GOGC=20
ExecStart=/root/kcptun/build/server_linux_amd64 -c /root/kcptun/build/server.json
Restart=on-failure
RestartSec=10
KillMode=process
LimitNOFILE=65536

最后在客户端创建配置文件(local.json):

{
	"localaddr": ":1080",
	"remoteaddr": "xxx.xxx.xxx.xxx:19901",
	"mode": "fast3",
	"nocomp": true,
	"autoexpire": 900,
	"sockbuf": 16777217,
	"dscp": 46
}

然后执行:

client_windows_amd64.exe -c client.json

到这里就可以通过 127.0.0.1:1080 代理上网啦。

另外还有一个小技巧,准备一个小型Web服务器,我这里是使用的 HFS,baidu应该很好下,将ss生成的pac文件放到web目录下面,
需要注意pac里面除了双斜杠开头,下面的第一句话,我这里把它改成了:

var proxy = "SOCKS5 127.0.0.1:1080; SOCKS 127.0.0.1:1080; DIRECT;";

根据需要修改IP、端口号、代理方式等等。

然后修改系统配置:网络和Internet 设置 -> 代理 -> 关闭 自动检测设置 -> 打开 使用设置脚本

在脚本地址里输入 HFSPAC文件的地址,我这里是:http://192.168.0.88/pac

浏览器使用系统代理设置,这样配置完后,会根据网址的PAC规则自动选择是否使用代理。

最后展示下成功图片:

posted @ 2020-02-12 01:16  MADE.BEER  阅读(2911)  评论(0编辑  收藏  举报