一、安装命令:
yum install python-setuptools && easy_install pip
pip install shadowsocks
二、创建 shadowsock 的配置文件(多用户多端口)
vi /etc/shadowsocks.json
配置内容:
{
“server”:”your_server_ip”,
“local_address”: “127.0.0.1”,
“local_port”:1080,
“port_password”:{
“8383”:”password0″,
“8384”:”password1″,
“8385”:”password2″,
“8386”:”password3″,
},
“timeout”:300,
“method”:”aes-256-cfb”,
“fast_open”: false
}
三、服务端启动命令
ssserver -c /etc/shadowsocks.json
如果想在后台一直运行 Shadowsocks,启动命令如下:
nohup ssserver -c /etc/shadowsocks.json > /dev/null 2>&1 &
四、优化 shadowsock 加速
我们通过修改 /etc/sysctl.conf 来达到调整的目的,命令:
vi /etc/sysctl.conf
修改以下内容:
fs.file-max = 51200
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.netdev_max_backlog = 250000
net.core.somaxconn = 4096net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_mem = 25600 51200 102400
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_congestion_control = hybla
记得修改完后,执行以下命令来生效。
sysctl -p
备注,可以让防火墙放行这些 ss 端口,命令如下:
vi /etc/sysconfig/iptables
-A INPUT -m state –state NEW -m tcp -p tcp –dport 8989 -j ACCEPT
service iptables restart
也可以修改下 limits.conf 达到 TCP 上限足够
* soft nofile 51200
* hard nofile 51200
然后使用一下命令让其生效:
ulimit -n 51200
至此,就可以愉快的玩耍 shadowsocks 啦。