CentOS 7 下搭建 Shadowsocks

Author Avatar
李欣 8月 16, 2017
  • 在其它设备中阅读本文章

CentOS 7 搭建 Shadowsocks

最近老是换VPS,频繁的搭SS。一直都是边查边搭,这里记录一下方便以后使用。

使用的方法是先安装pip,再安装shdowsocks

1. 安装 pip

1.1 安装 epel 扩展源

sudo yum install epel-release

1.2 安装 python-pip

sudo yum -y install python-pip

1.3 升级 pip

由于 CentOS 大家都懂的原因,pip的版本不一定是足够新的,所以保险升级一下。

sudo pip install --upgrade pip

显示Complete!后表示安装成功,最好清除下cache。

sudo yum clean all

2. 安装 Shdowsocks

pip install shadowsocks

2.1 配置服务端口

新建一个配置文件

vi /etc/shadowsocks.json

单用户使用输入如下内容:

{ 
   "server":"server_ip", 
   "server_port":25, 
   "local_address": "127.0.0.1", 
   "local_port":1080, 
   "password":"password",
    "timeout":300, 
   "method":"aes-256-cfb", 
   "fast_open": false 
}

多用户支持可以如下设置:

{
    "server":"server_ip",
    "port_password":{
        "port_1":"pwd1",
        "port_2":"pwd2",
        "port_3":"pwd3"
    },
    "local_address":"127.0.0.1",
    "local_port":1080,
    "timeout":300,
    "method":"aes-256-cfb"
}

tips

主要需要设置 server_ipportpassword 三项,设置好后保存退出。

  • server_ip 填写你服务器的公网IP地址
  • port 填写你想设置的SS端口
  • password 填写你想设置的SS密码

2.2 启动 Shadowsocks

最好将其设置成服务启动。

vi /etc/systemd/system/shadowsocks.service

然后输入以下内容:

[Unit]
Description=Shadowsocks

[Service]
TimeoutStartSec=0
ExecStart=/usr/bin/ssserver -c /etc/shadowsocks.json

[Install]
WantedBy=multi-user.target

启动服务

systemctl enable shadowsocks
systemctl start shadowsocks

查看服务是否启动成功:

systemctl status shadowsocks -l

如需要停止服务使用:

systemctl stop shadowsocks

2.3 开启防火墙端口

如果没设置防火墙端口开启,可能不能访问到该端口服务。

以端口12345为例

firewall-cmd --zone=public --add-port=12345/tcp --permanent

3.加速

加速可以选择用Kcptun或者BBR,这里就不赘述了。

This blog is under a CC BY-NC-SA 3.0 Unported License
本文链接:http://Great-Li-Xin.github.io/2017/08/16/centos-ss/