CentOS搭建Shadowsocks服务-实现科学上网
source link: https://www.csdndocs.com/article/9554356
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
安装配置 shadowsocks
执行以下命令安装shadowsocks
yum -y install python-setuptools && easy_install shadowsocks
新建shadowsocks配置文件
mkdir /etc/shadowsocks && touch /etc/shadowsocks/config.json
编辑这个配置文件
vim /etc/shadowsocks/config.json
如果是单账户:
{ "server": "your_server_ip", "server_port": 8001, "password": "your_password", "local_port":1080, "timeout":300, "method": "aes-256-cfb", "fast_open": false}
server:服务器ip地址
server_port:绑定的端口,注意不要设置已经使用了的端口
possword: 密码
local_port 本地端口,一般默认1080
timeout:超时时间
method:加密方法
fast_open:如果你的服务器 Linux 内核在3.7+,可以开启 fast_open 以降低延迟
如果是多账户
{"server":"your_server_ip","port_password":{ "8001":"password1", "8002":"password2", "8003":"password3", "8004":"password4" },"local_port":1080,"timeout":300,"method":"rc4-md5","fast_open":false}
编写运行脚本
新建一个运行脚本
vim /etc/shadowsocks/shadowsocks
#!/bin/bashss_start(){ if [ ! -f /run/shadowsocks.pid ] then ssserver -c /etc/shadowsocks/config.json -d start fi}ss_stop(){ if [ -f /run/shadowsocks.pid ] then ssserver -c /etc/shadowsocks/config.json -d stop fi}if [ $# -eq 0 ]then ss_startelif [ $1 == "start" ]then ss_startelif [ $1 == "stop" ]then ss_stopelif [ $1 == "restart" ]then ss_stop ss_startelse echo "${1} Invalid"fi
添加执行权限
chmod +x /etc/shadowsocks/shadowsocks
配置自启动
新建服务配置文件
vim /etc/systemd/system/shadowsocks.service
内容如下:
[Unit]Description=shadowsocksAfter=network.target[Service]Type=forkingPIDFile=/run/shadowsocks.pidExecStartPre=/bin/sleep 1ExecStart=/etc/shadowsocks/shadowsocks startExecStop=/etc/shadowsocks/shadowsocks stopPrivateTmp=true[Install]WantedBy=multi-user.target
然后载入这个服务配置文件
systemctl daemon-reload
执行以下命令启动 shadowsocks 服务:
systemctl start shadowsocks
并设置自启动
systemctl enable shadowsocks
为了检查 shadowsocks 服务是否已成功启动,可以执行以下命令查看服务的状态:
systemctl status shadowsocks
客户端配置
Windows: 下载Shadowsocks-3.4.3.zip
Mac OS X:下载ShadowsocksX-NG-1.4-beta.zip
Android : 下载shadowsocks_3.3.1.apk
iOS:转到App Store
或转到官方下载页:https://shadowsocks.org/en/download/clients.html
以Windows客户端为例,进入服务器选项-编辑服务器-添加,各项参数配置如下图示
其中各项参数按照服务端的配置填入后确定,点击右键-启用系统代理。
其他客户端的配置方法与Windows客户端基本相同。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK