记一次socks5部署时的坑

1、第一步我们来安装服务需要的一些依赖服务:

  1. [root@Sh_Test ~]# yum -y install gcc gcc-c++ automake make pam-devel openldap-devel cyrus-sasl-devel openssl-devel

2、在 SS5 官网下载SS5最新版本的源代码 SS5官网地址:http://ss5.sourceforge.net/ 这里目前可以下载的最新版链接如下:(由于文件服务器在国内没有节点,下载可能会比较慢) https://jaist.dl.sourceforge.net/project/ss5/ss5/3.8.9-8/ss5-3.8.9-8.tar.gz

  1. [root@Sh_Test ~]# wget https://jaist.dl.sourceforge.net/project/ss5/ss5/3.8.9-8/ss5-3.8.9-8.tar.gz

3、解压、编译源码安装ss5服务

  1. [root@Sh_Test ~]# tar zxf ss5-3.8.9-8.tar.gz -C /usr/local/
  2. [root@Sh_Test ~]# cd /usr/local/ss5-3.8.9/
  3. [root@Sh_Test ss5-3.8.9]# ./configure && make && make install

4、启动服务(启动脚本默认没有执行权限,需要手动赋权)

  1. [root@Sh_Test ~]# /etc/rc.d/init.d/ss5 start
  2. -bash: /etc/rc.d/init.d/ss5: 权限不够
  3. [root@Sh_Test ~]# ll /etc/rc.d/init.d/ss5
  4. -rw-r--r-- 1 root root 1613 7月 12 16:28 /etc/rc.d/init.d/ss5
  5. [root@Sh_Test ~]# chmod 744 /etc/rc.d/init.d/ss5
  6. [root@Sh_Test ~]# /etc/rc.d/init.d/ss5 start
  7. Reloading systemd: [ 确定 ]
  8. Starting ss5 (via systemctl): [ 确定 ]

5、两种模式配置

a、无用户认证模式: 启用 ss5.conf 配置文件中的下列两行配置:

  1. [root@Sh_Test ~]# egrep -v '^#|^$' /etc/opt/ss5/ss5.conf
  2. auth 0.0.0.0/0 - -
  3. permit - 0.0.0.0/0 - 0.0.0.0/0 - - - - -

验证: (linux下使用 curl 命令加 –socks5 参数指定代理地址访问)

  1. root@BJ-CentOS7 ~ # curl myip.ipip.net
  2. 当前 IP:123.206.14.147 来自于:中国 天津 天津 电信/联通/移动
  3. root@BJ-CentOS7 ~ # curl myip.ipip.net --socks5 118.89.106.69:1080
  4. 当前 IP:118.89.106.69 来自于:中国 上海 上海 电信/联通/移动

b、用户密码认证方式 修改 ss5.conf 配置文件中的下列两行配置,ss5.passwd中添加用户密码,每行一对用户+密码,使用空间隔开

  1. [root@Sh_Test ~]# egrep -v '^#|^$' /etc/opt/ss5/ss5.conf
  2. auth 0.0.0.0/0 - u
  3. permit u 0.0.0.0/0 - 0.0.0.0/0 - - - - -
  4. [root@Sh_Test ~]# cat /etc/opt/ss5/ss5.passwd
  5. test test
  6. [root@Sh_Test ~]# systemctl restart ss5

验证: (linux下使用 curl 命令加 –socks5 参数指定代理地址访问) 此时不指定用户密码的情况下无法正常使用代理地址做请求:

  1. root@BJ-CentOS7 ~ # curl myip.ipip.net --socks5 118.89.106.69:1080
  2. curl: (7) No authentication method was acceptable. (It is quite likely that the SOCKS5 server wanted a username/password, since none was supplied to the server on this connection.)
  3. root@BJ-CentOS7 ~ # curl myip.ipip.net
  4. 当前 IP:123.206.14.147 来自于:中国 天津 天津 电信/联通/移动
  5. root@BJ-CentOS7 ~ # curl myip.ipip.net --socks5 test:test@118.89.106.69:1080
  6. 当前 IP:118.89.106.69 来自于:中国 上海 上海 电信/联通/移动

注意:安装完成后的配置文件位置不在安装目录下,而是在/etc/opt/ss5目录下,只有这个位置下得文件生效

客户机全局使用:

export http_proxy=socks5://test:test@xxx:1080

export http_proxy=socks5://test:test@xxx:1080

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
要基于 Netty 实现一个 SOCKS5 服务器,可以按照以下步骤进行: 1. 创建一个 Netty 的 ServerBootstrap 对象,并设置其相关属性,例如监听端口号、处理器等。 2. 在处理器中实现 SOCKS5 协议的解析和处理。对于 SOCKS5 协议,客户端会发送一个 Greeting 消息,服务器需要回复一个 Greeting 消息确认连接。然后客户端会发送一个请求,包括请求类型、目标地址和端口等信息,服务器需要根据请求类型进行相应的处理,例如连接目标地址和端口、绑定到指定的地址和端口等。 3. 在处理器中实现数据的转发,当客户端和目标服务器建立连接后,服务器需要将数据从客户端转发给目标服务器,然后将目标服务器返回的数据转发给客户端。 下面是一个简单的示例代码: ```java public class Socks5Server { public static void main(String[] args) throws InterruptedException { EventLoopGroup bossGroup = new NioEventLoopGroup(); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) .childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast(new Socks5ServerEncoder()); pipeline.addLast(new Socks5InitialRequestDecoder()); pipeline.addLast(new Socks5ServerHandler()); } }); ChannelFuture future = bootstrap.bind(1080).sync(); future.channel().closeFuture().sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } } } ``` 在上面的代码中,创建了一个 ServerBootstrap 对象,并设置了监听端口号为 1080,处理器为 Socks5ServerHandler。Socks5ServerHandler 实现了 SOCKS5 协议的解析和处理,以及数据的转发。 需要注意的是,这只是一个简单的示例代码,实际使用中可能需要根据具体需求进行扩展和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值