Raspberry Pi 安装 Kcptun

声明

Kcptun的作用主要是配合SS用来做加速,试过把Kcptun安装到路由器中,由于性能和稳定性的问题效果不如安装到树莓派上面效果好,配合systemd可以做到开机启动和进程断掉重启服务。配置比较简单,下文的配置方式用来给大家参考。

相关资料

官网
    https://github.com/xtaci/kcptun

下载地址
    https://github.com/xtaci/kcptun/releases/latest

其他资源
    https://blog.kuoruan.com/102.html

服务搭建

下载
    cd /usr/local/opt/
    mkdir kcptun
    cd kcptun
    wget .../kcptun-linux-amd64.tar.gz
    tar -zxf kcptun-linux-amd64.tar.gz

创建 systemd service
    vi /etc/systemd/system/kcptun-server.service

kcptun-server.service 文件内容
    [Unit]
    Description=Start or stop the kcptun-server
    After=network.target
    Wants=network.target
    [Service]
    ExecStart=/usr/local/opt/kcptun/server_linux_amd64 --key "username" -t "127.0.0.1:443" -mtu 1400 -sndwnd 2048 -rcvwnd 2048 -mode fast2
    Restart=1
    [Install]
    WantedBy=multi-user.target

配置说明
    -t "127.0.0.1:443"     指定的是本机地址和shadowsocks的端口
    -mode                  加速模式,fast3 > fast2 > fast > normal > default
    -h                     可查看其他参数说明

启动
    systemctl start kcptun-server

关闭
    systemctl stop kcptun-server

查看状态
    systemctl status kcptun-server

设置开机启动
    systemctl enable kcptun-server

Raspberry Pi 设置

下载安装
    cd /usr/local/opt/
    mkdir kcptun
    cd kcptun
    wget .../kcptun-linux-arm.tar.gz
    tar -zxf kcptun-linux-arm.tar.gz

创建 systemd service
    vi /etc/systemd/system/kcptun-client.service

kcptun-client.service 文件内容
    [Unit]
    Description=Start or stop the kcptun-client
    After=network.target
    Wants=network.target
    [Service]
    ExecStart=/usr/local/opt/kcptun/client_linux_arm7 --key "username" -r "45.78.32.99:29900" -l ":443" -mtu 1400 -sndwnd 256 -rcvwnd 2048 -mode fast2 -dscp 46
    Restart=1
    [Install]
    WantedBy=multi-user.target

启动
    systemctl start kcptun-client

关闭
    systemctl stop kcptun-client

查看状态
    systemctl status kcptun-client

设置开机启动
    systemctl enable kcptun-client