基于CentOS6.X安装TG高可用的Socks5代理

Sock(socket security,SOCKS)是一种基于传输层的网络代理协议。对于各种基于 TCP/IP的应用层协议都能够适应。它能够忠实地转发客户端-服务器打的通讯包,完成协议本来要完成的功能。现在的协议是v5,也就是Scok5协议。使用Scok5协议的代理服务器即称为Sock5代理。

很多国外软件需要越墙才能使用,如果当木弟【和谐】子不能使用的时候,我们如何使用tg展开安全加密通讯?
答案是有办法的,socks5代理即可轻松解决此问题。

1、

yum -y install vim  gcc openldap-devel pam-devel openssl-devel  automake  make cyrus-sasl-devel && echo "ok"

2、

wget https://nchc.dl.sourceforge.net/project/ss5/ss5/3.8.9-8/ss5-3.8.9-8.tar.gz
   ##备用地址:https://iloveyouqq.cn/soft/proxy/ss5-3.8.9-8.tar.gz

3、

tar xvf ss5-3.8.9-8.tar.gz

4、

cd ss5-3.8*;./configure && make && make install && echo "ok"

设置访问方式为密码:

[[email protected] ss5]# vim /etc/opt/ss5/ss5.conf 
#用户密码访问鉴权。
auth 0.0.0.0/0 - u
permit u 0.0.0.0/0 - 0.0.0.0/0 - - - - -

添加用户名和密码:

[[email protected] ss5]# cat /etc/opt/ss5/ss5.passwd 
#用户名 密码
hello 123
mike yes

在启动脚本中定义监听的端口为8080:

[[email protected] ss5]# grep "SS5_SOCKS_" /etc/init.d/ss5 ;chmod u+x /etc/init.d/ss5
export SS5_SOCKS_PORT=8080
export SS5_SOCKS_USER=root

启动脚本(/etc/init.d/ss5):


#!/bin/sh
#
# chkconfig: 345 20 80
# description: This script takes care of starting \
#              and stopping ss5
#

export SS5_SOCKS_PORT=8080
export SS5_SOCKS_USER=root

OS=`uname -s`
if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then
 
# Source function library.
 . /etc/rc.d/init.d/functions

# Source networking configuration.
 . /etc/sysconfig/network

# Check that networking is up.
 [ ${NETWORKING} = "no" ] && exit 0

 [ -f /usr/sbin/ss5 ] || exit 0
fi

# Test custom variables
test -f /etc/sysconfig/ss5 && . /etc/sysconfig/ss5

# See how we were called.
case "$1" in
  start)
        # Start daemon.
        echo -n "Starting ss5... "
    if [ $OS = "Linux" ]; then
            daemon /usr/sbin/ss5 -t $SS5_OPTS
            touch /var/lock/subsys/ss5
    else
      if [ $OS = "SunOS" ]; then
              /usr/sbin/ss5 -t 
              touch /var/lock/subsys/ss5
      else
              /usr/local/sbin/ss5 -t 
      fi
    fi
    echo "done"
        ;;
  stop)
        # Stop daemon.
        echo "Shutting down ss5... "
    if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then
    killproc ss5
        rm -f /var/lock/subsys/ss5
    else
        killall ss5
    fi
        rm -f /var/run/ss5/ss5.pid
    echo "done"
        ;;
  reload)
        # Reload configuration
    if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then
        echo -n "Reloading ss5... "
    killproc ss5 -1
    else
        pkill -HUP ss5
    fi
    echo "done reload"
    ;;
  restart)
        # Restart daemon
        echo -n "Restarting ss5... "
    $0 stop
    $0 start
    ;;
  status)
    if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then
      status ss5
    fi
    ;;
  *)
        echo "Usage: ss5 {start|stop|status|restart|reload}"
        exit 1
    ;;
esac
exit 0

如果设置有防火墙,那就添加规则进行放行ss5的端口。

iptables -t filter -I INPUT -p tcp --dport 8080 -j ACCEPT

标签: socks5, proxy, centos

仅有一条评论

  1. 来围观啦。

添加新评论