配置Server

下载

到github仓库xtaci/kcptun下载对应服务器最新版本

配置文件

创建配置文件,如/etc/kcptun/server.json

{
        "listen": ":2000",
        "target": "127.0.0.1:9999",
        "key": "PASSWORD",
        "crypt": "aes",
        "mode": "fast3",
        "mtu": 1400,
        "sndwnd": 2048,
        "rcvwnd": 2048,
        "datashard": 10,
        "parityshard": 3,
        "dscp": 46,
        "nocomp": true,
        "acknodelay": false,
        "nodelay": 1,
        "interval": 40,
        "resend": 2,
        "nc": 1,
        "sockbuf": 16777217,
        "smuxver": 1,
        "smuxbuf": 16777217,
        "streambuf": 2097152,
        "keepalive": 10,
        "pprof":false,
        "quiet":false,
        "tcp":false,
        "log": "/var/log/kcptun/kcptun.log"
}

创建日志文件目录

mkdir -p /var/log/kcptun

配置服务

创建并配置服务文件kcptun-server.service

[Unit]
Description=Kcptun
After=network.target

[Service]
ExecStart=/usr/local/bin/kcptun-server -c /etc/kcptun/server.json
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

[Install]
WantedBy=multi-user.target

启用服务并启动

systemctl enable kcptun_server.service
service kcptun_server start