Centos7搭建Shadowsocks

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:322

Centos7搭建Shadowsocks搭建shadowsocks很简单,直接yum安装即可。
安装相关组件yum install -y gcc automake autoconflibtool makeyum install -y curl-devel zlib-developenssl-devel perl-devel expat-devel gettext-devel通过github安装shadowsocksgit clone https://github.com/madeye/shadowsocks-libev.gitcd shadowsocks-libev./configure && makemake install 创建开机脚本vi /etc/init.d/shadowsocks #填写下方脚本#!/bin/bash# chkconfig: 2345 99 99# Source function library. /etc/rc.d/init.d/functions# Check that networking is up.[ ${NETWORKING} ="yes" ] || exit 0# DaemonNAME=shadowsocks-serverDAEMON=/usr/local/bin/ss-server# Path to the configuration file.CONF=/etc/shadowsocks/config.json#USER="nobody"#GROUP="nobody"# Take care of pidfile permissionsmkdir /var/run/$NAME 2>/dev/null || true#chown "$USER:$GROUP" /var/run/$NAME# Check the configuration file exists.if [ ! -f $CONF ] ; thenecho "The configuration file cannot be found!"exit 0fi# Path to the lock file.LOCK_FILE=/var/lock/subsys/shadowsocks# Path to the pid file.PID=/var/run/$NAME/pid# Run controls:RETVAL=0# Start shadowsocks as daemon.start() {if [ -f $LOCK_FILE ]; thenecho "$NAME is already running!"exit 0elseecho -n $"Starting ${NAME}: "#daemon --check $DAEMON --user $USER "$DAEMON -f$PID -c $CONF > /dev/null"daemon $DAEMON -c $CONF -f $PIDfiRETVAL=$?[ $RETVAL -eq 0 ] && successecho[ $RETVAL -eq 0 ] && touch $LOCK_FILEreturn $RETVAL}# Stop shadowsocks.stop() {echo -n $"Shutting down ${NAME}: "killproc -p ${PID}RETVAL=$?[ $RETVAL -eq 0 ]rm -f $LOCK_FILErm -f ${PID}echoreturn $RETVAL} # See how we were called.case "$1" instart)start;;stop)stop;;restart)stopstart;;condrestart)if [ -f $LOCK_FILE ]; thenstopstartRETVAL=$?fi;;status)status $DAEMONRETVAL=$?;;*)echo $"Usage: $0{start|stop|restart|condrestart|status}"RETVAL=1esacexit $RETVAL 创建config.json并填写相关账号信息mkdir -p /etc/shadowsocksvi /etc/shadowsocks/config.json"server":"服务器 IP 地址","server_port":8388,"local_address": "127.0.0.1","local_port":1080,"password":"mypassword","timeout":300,"method":"aes-256-cfb","fast_open": false,"workers": 1 各个字段的意思:最后赋予shadowsocks执行权限并添加开机启动即可各个字段的意思: 字段名 含义server 服务端监听的地址,服务端可填写 0.0.0.0server_port 服务端的端口local_address 本地端监听的地址local_port 本地端的端口password 用于加密的密码timeout 超时时间,单位秒method 默认 “aes-256-cfb”,参见加密方法fast_open 是否使用 TCP_FASTOPEN,true / falseworkers worker 数量,Unix/Linux 可用,如果不理解含义请不要改 最后赋予shadowsocks执行权限并添加开机启动即可 chmod 755 /etc/init.d/shadowsocks chkconfig --add shadowsocks systemctl start shadowsocks

本文标签:
本文标题:Centos7搭建Shadowsocks
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】