-
Ubuntu 14.04 64位环境部署多端口Shadowsocks服务端
-
启用相对更节约资源的CHACHA20加密
-
部署更快速的KCPTUN服务端
-
在Android和Windows环境下KCPTUN客户端的配置
-
安装必要组件
- 更新系统,安装可以直接从apt更新的软件:
apt-get update
apt-get upgrade
apt-get install build-essential python-pip m2crypto supervisor
安装shadowsocks:
pip install shadowsocks
安装加密用软件libsodium:
wget https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz
tar zxvf libsodium-1.0.11.tar.gz
cd libsodium-1.0.11
./configure
make && make check
make install
echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig
- 配置shadowsocks 编辑shadowsocks配置文件:
vi /etc/shadowsocks.json
按I进入插入模式,粘贴后按Esc退出,光标选中需要修改的位置按X删除,再进入插入模式修改。
最后按Esc退出,再输入:wq保存退出。
下面配置文件中1080和8080为服务端口号,后面为对应的密码,可以不同。
{
"server":"0.0.0.0",
"port_password":
{
"1080":"password1",
"8080":"password2"
},
"timeout":600,
"method":"chacha20",
"auth": true
}
编辑supervisor的配置文件:
vi /etc/supervisor/conf.d/shadowsocks.conf
如果需要选定1024内的端口号,可能必须用root用户。
[program:shadowsocks]
command=ssserver -c /etc/shadowsocks.json
autorestart=true
user=root
现在即可通过下面的命令启动shadowsocks服务端,并检查其状态:
supervisorctl reload
supervisorctl status
- KCPTUN的部署 下载安装KCPTUN:
mkdir /root/kcptun
cd /root/kcptun
ln -sf /bin/bash /bin/sh
wget https://github.com/xtaci/kcptun/releases/download/v20161118/kcptun-linux-amd64-20161118.tar.gz
tar -zxf kcptun-linux-amd64-*.tar.gz
配置KCPTUN启动文件:
vi /root/kcptun/start.sh
#!/bin/bash
cd /root/kcptun/
./server_linux_amd64 -c /root/kcptun/server-config.json > kcptun.log 2>&1 &
echo "Kcptun started."
vi /root/kcptun/server-config.json
{ "listen": ":443", "target": "127.0.0.1:1080", "key": "test", "crypt": "salsa20", "mode": "fast2", "mtu": 1350, "sndwnd": 1024, "rcvwnd": 1024, "datashard": 70, "parityshard": 30, "dscp": 46, "nocomp": false, "acknodelay": false, "nodelay": 0, "interval": 40, "resend": 0, "nc": 0, "sockbuf": 4194304, "keepalive": 10 }
vi /root/kcptun/stop.sh
#!/bin/bash
echo "Stopping Kcptun..."
PID=ps -ef | grep server_linux_amd64 | grep -v grep | awk '{print $2}'
if [ "" != "$PID" ]; then
echo "killing $PID"
kill -9 $PID
fi
echo "Kcptun stoped."
sh /root/kcptun/start.sh sh /root/kcptun/stop.sh
chmod +x /etc/rc.local;echo "sh /root/kcptun/start.sh" >> /etc/rc.local
WINDOWS VBS run.vbs
Dim RunKcptun Set fso = CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell") '获取文件路径 currentPath = fso.GetFile(Wscript.ScriptFullName).ParentFolder.Path & "" '配置文件路径 configFile = currentPath & "client-config.json" '日志文件 logFile = currentPath & "kcptun.log" '软件运行参数 exeConfig = currentPath & "client_windows_amd64.exe -c " & configFile '拼接命令行 cmdLine = "cmd /c " & exeConfig & " > " & logFile & " 2>&1" '启动软件 WshShell.Run cmdLine, 0, False '等待1秒 'WScript.Sleep 1000 '打印运行命令 'Wscript.echo cmdLine Set WshShell = Nothing Set fso = Nothing '退出脚本 WScript.quit
client-config.json
{ "localaddr": ":132466", "remoteaddr": "10.10.10.10:443", "key": "test", "crypt": "salsa20", "mode": "fast2", "conn": 1, "autoexpire": 60, "mtu": 1350, "sndwnd": 128, "rcvwnd": 1024, "datashard": 70, "parityshard": 30, "dscp": 46, "nocomp": false, "acknodelay": false, "nodelay": 0, "interval": 40, "resend": 0, "nc": 0, "sockbuf": 4194304, "keepalive": 10 }
stop.bat
taskkill /f /im client_windows_amd64.exe