首页 IT正文

Centos7搭建Shadowsocks

admin IT 2017-10-27 231 0

搭建shadowsocks很简单,直接yum安装即可。


安装相关组件

1yum install -y gcc automake autoconf libtool make
2yum install -y curl-devel zlib-devel openssl-devel perl-devel expat-devel gettext-devel

通过github安装shadowsocks

1git clone https://github.com/madeye/shadowsocks-libev.git
2cd shadowsocks-libev
3./configure && make
4make install

创建开机脚本

1vi /etc/init.d/shadowsocks   #填写下方脚本
001#!/bin/bash
002#
003# Script to run Shadowsocks in daemon mode at boot time.
004# ScriptAuthor: icyboy
005# Revision 1.0 - 14th Sep 2013
006#====================================================================
007# Run level information:
008# chkconfig: 2345 99 99
009# Description: lightweight secured scoks5 proxy
010# processname: ss-server
011# Author: Max Lv <max.c.lv@gmail.com>;
012# Run "/sbin/chkconfig --add shadowsocks" to add the Run levels.
013#====================================================================
014
015#====================================================================
016# Paths and variables and system checks.
017
018# Source function library
019/etc/rc.d/init.d/functions
020
021# Check that networking is up.
022#
023[ ${NETWORKING} ="yes" ] || exit 0
024
025# Daemon
026NAME=shadowsocks-server
027DAEMON=/usr/local/bin/ss-server
028
029# Path to the configuration file.
030#
031CONF=/etc/shadowsocks/config.json
032
033#USER="nobody"
034#GROUP="nobody"
035
036# Take care of pidfile permissions
037mkdir /var/run/$NAME 2>/dev/null || true
038#chown "$USER:$GROUP" /var/run/$NAME
039
040# Check the configuration file exists.
041#
042if [ ! -f $CONF ] ; then
043echo "The configuration file cannot be found!"
044exit 0
045fi
046
047# Path to the lock file.
048#
049LOCK_FILE=/var/lock/subsys/shadowsocks
050
051# Path to the pid file.
052#
053PID=/var/run/$NAME/pid
054
055
056#====================================================================
057
058#====================================================================
059# Run controls:
060
061RETVAL=0
062
063# Start shadowsocks as daemon.
064#
065start() {
066if [ -f $LOCK_FILE ]; then
067echo "$NAME is already running!"
068exit 0
069else
070echo -n $"Starting ${NAME}: "
071#daemon --check $DAEMON --user $USER "$DAEMON -f $PID -c $CONF > /dev/null"
072daemon $DAEMON -c $CONF -f $PID
073fi
074
075RETVAL=$?
076[ $RETVAL -eq 0 ] && success
077echo
078[ $RETVAL -eq 0 ] && touch $LOCK_FILE
079return $RETVAL
080}
081
082
083# Stop shadowsocks.
084#
085stop() {
086echo -n $"Shutting down ${NAME}: "
087killproc -p ${PID}
088RETVAL=$?
089[ $RETVAL -eq 0 ]
090rm -f $LOCK_FILE
091rm -f ${PID}
092echo
093return $RETVAL
094}
095
096# See how we were called.
097case "$1" in
098start)
099start
100;;
101stop)
102stop
103;;
104restart)
105stop
106start
107;;
108condrestart)
109if [ -f $LOCK_FILE ]; then
110stop
111start
112RETVAL=$?
113fi
114;;
115status)
116status $DAEMON
117RETVAL=$?
118;;
119*)
120echo $"Usage: $0 {start|stop|restart|condrestart|status}"
121RETVAL=1
122esac
123
124exit $RETVAL

创建config.json并填写相关账号信息

1mkdir -p /etc/shadowsocks
2vi /etc/shadowsocks/config.json  #填写下方参数
01{
02    "server":"服务器 IP 地址",
03    "server_port":8388,
04    "local_address""127.0.0.1",
05    "local_port":1080,
06    "password":"mypassword",
07    "timeout":300,
08    "method":"aes-256-cfb",
09    "fast_open"false,
10    "workers": 1
11}

各个字段的意思:

字段名含义
server服务端监听的地址,服务端可填写 0.0.0.0
server_port服务端的端口
local_address本地端监听的地址
local_port本地端的端口
password用于加密的密码
timeout超时时间,单位秒
method默认 “aes-256-cfb”,参见加密方法
fast_open是否使用 TCP_FASTOPEN, true / false
workersworker 数量,Unix/Linux 可用,如果不理解含义请不要改

最后赋予shadowsocks执行权限并添加开机启动即可

1chmod 755 /etc/init.d/shadowsocks
2chkconfig --add shadowsocks
3systemctl start shadowsocks

 
本文标题:Centos7搭建Shadowsocks
使用说明:https://github.com/clowwindy/shadowsocks/wiki
               https://github.com/madeye/shadowsocks-libev
本文地址:https://miefen.com/201410/how-to-install-shadowsocks-on-centos-7


本文标题:Centos7搭建Shadowsocks
本文链接:https://xl.cndyun.com/post/177.html
作者授权:除特别说明外,本文由 admin 原创编译并授权 小龙的博客 刊载发布。
版权声明:本文不使用任何协议授权,您可以任何形式自由转载或使用。
«   2019年9月   »
1
2345678
9101112131415
16171819202122
23242526272829
30
阿里云
【开年好云 钜惠来袭】2019新春采购节,30款云产品感恩回馈

当前网页二维码

分享:

支付宝

微信