搭建shadowsocks很简单,直接yum安装即可。
安装相关组件
1 |
yum install -y gcc automake autoconf libtool make |
2 |
yum install -y curl-devel zlib-devel openssl-devel perl-devel expat-devel gettext-devel |
通过github安装shadowsocks
1 |
git clone https: //github .com /madeye/shadowsocks-libev .git |
创建开机脚本
1 |
vi /etc/init .d /shadowsocks |
019 |
. /etc/rc .d /init .d /functions |
023 |
[ ${NETWORKING} = "yes" ] || exit 0 |
026 |
NAME=shadowsocks-server |
027 |
DAEMON= /usr/local/bin/ss-server |
031 |
CONF= /etc/shadowsocks/config .json |
037 |
mkdir /var/run/ $NAME 2> /dev/null || true |
042 |
if [ ! -f $CONF ] ; then |
043 |
echo "The configuration file cannot be found!" |
049 |
LOCK_FILE= /var/lock/subsys/shadowsocks |
053 |
PID= /var/run/ $NAME /pid |
066 |
if [ -f $LOCK_FILE ]; then |
067 |
echo "$NAME is already running!" |
070 |
echo -n $ "Starting ${NAME}: " |
072 |
daemon $DAEMON -c $CONF -f $PID |
076 |
[ $RETVAL - eq 0 ] && success |
078 |
[ $RETVAL - eq 0 ] && touch $LOCK_FILE |
086 |
echo -n $ "Shutting down ${NAME}: " |
109 |
if [ -f $LOCK_FILE ]; then |
120 |
echo $ "Usage: $0 {start|stop|restart|condrestart|status}" |
创建config.json并填写相关账号信息
1 |
mkdir -p /etc/shadowsocks |
2 |
vi /etc/shadowsocks/config .json |
04 |
"local_address" : "127.0.0.1" , |
06 |
"password" : "mypassword" , |
08 |
"method" : "aes-256-cfb" , |
各个字段的意思:
字段名 |
含义 |
server |
服务端监听的地址,服务端可填写 0.0.0.0 |
server_port |
服务端的端口 |
local_address |
本地端监听的地址 |
local_port |
本地端的端口 |
password |
用于加密的密码 |
timeout |
超时时间,单位秒 |
method |
默认 “aes-256-cfb”,参见加密方法 |
fast_open |
是否使用 TCP_FASTOPEN, true / false |
workers |
worker 数量,Unix/Linux 可用,如果不理解含义请不要改 |
最后赋予shadowsocks执行权限并添加开机启动即可
1 |
chmod 755 /etc/init .d /shadowsocks |
2 |
chkconfig --add shadowsocks |
3 |
systemctl start shadowsocks |
(责任编辑:IT) |