Ubuntu/Debian/CentOS搭建Socks5代理一键脚本

说明

Socks5属于明文代理,不要用于科学上网,否则会被阻断端口,可用于正常的跳板使用;
比如SSH转发加速国外VPS的连接速度,特别是一些延迟高或者丢包高的VPS
使用Socks5转发后SSH就可以快速稳定的连接了,解决高丢包SSH断开的问题;

支持

支持系统
Debian7+ Ubuntu14.04+ CentOS6+

安装

下载脚本

wget --no-check-certificate https://raw.github.com/Lozy/danted/master/install.sh -O install.sh

安装脚本

bash install.sh  --port=端口 --user=用户名 --passwd=密码

其中的端口 用户名 密码自行修改后粘贴到SSH里运行安装即可;
完成后会提示Dante Server Install Successfuly即表示安装成功;
安装后如果连接不上,检查设置的端口是否已经放行;
说明:安装完成后会显示内网IP地址,但在实际使用的时候需要用外网IP地址;

使用

一般使用IP和用户名密码即可使用
如果需要固定IP或IP段,可以修改配置文件设置白名单

vi /etc/danted/sockd.conf

修改以下代码,改成你需要设置的白名单IP或IP段即可,然后重启使其生效;

client pass {
        from: 0.0.0.0/0  to: 0.0.0.0/0
}

卸载

bash install.sh --uninstall

命令

命令或者说明
service sockd start/etc/init.d/sockd start启动socks5服务器守护进程
service sockd stop/etc/init.d/sockd stop停止socks5服务器守护进程
service sockd restart/etc/init.d/sockd restart重新启动socks5服务器守护进程
service sockd reload/etc/init.d/sockd reload重新加载socks5服务器守护进程
service sockd status/系统进程状态
service sockd state/etc/init.d/sockd state运行状态
service sockd tail/etc/init.d/sockd tailsock 日志
service sockd adduser/etc/init.d/sockd adduser添加pam-auth用户:service sockd adduser NAME PASSWORD
service sockd deluser/etc/init.d/sockd deluser删除pam-auth用户:service sockd deluser NAME

发表评论

45 条评论

  1. lobster

    挺好用的,一键成功

  2. kun

    debian 10 搭建总是失败,测试了好几个服务器,每一个成功的, CentOS 7 没有问题,都是一次成功,何解?

  3. hi

    请问怎么取消需要用户跟密码验证,只需要IP跟端口就行了

  4. 许仙

    感谢博主,刚好现在疫情 有个特殊需求,甲方用的sslvpn 同时要求我们自己也搭一个vpn 现在通过但是大多数VPN都是ssl的 太混乱, 今天搜了一下socks5的方式试试,已经搭建成功,接下来就是看看 socks5 和sslvpn能不能同时使用了

  5. dy6

    我的vps配置了多个IP地址如何使这多个IP地址都用上,麻烦看到能讲解下,谢谢

  6. 蛮大人

    大佬 全局模式无法登录谷歌是什么问题? 阿里云的远程登录一键搭建后出现用户账户密码错误是什么问题啊

  7. liqi

    怎么限制链接数量 求大神交下

  8. llco

    你好用香港服务器有反应 用洛杉矶的服务器就安装不了 输入脚本没反应 这个是什么情况

  9. llccool

    大神你好,如果服务器有2块网卡分别绑定2个公网ip。如何定义哪个账号走哪个ip来代理?

  10. 楼主好

    楼主大神, 搭建的Socks5为什么不能上谷歌啊,有什么办法可以解决吗? 或者要搭建其他的代理? 求指教

  11. 大白

    楼主您好,麻烦问一下 我用一台服务器设置了两个弹性网卡的公网IP但是连接之后还是会显示我装载的那个公网IP啊

  12. 涸辙

    楼主您好,我用911S5代理访问网页,在谷歌账号登录记录里是显示对应地区的,但是我自己的VPS用S5协议,却并不显示地区,请问这是什么原因呢

  13. 周可乐

    大佬报错怎么整
    error: attempt to determine function prototypes failed,
    and will probably mean that building of libdsocks,
    which allows on-the-fly socksification of dynamic
    binaries, will not work.

    You have several options:

    1. If you do not need libdsocks, run configure with the
    option --disable-preload.
    2. Submit a bugreport.
    3. Find the prototypes used on your platform for the
    failed functions, and add them to the configure.ac
    file. Then use autoconf (which must be installed)
    to regenerate the configure script.
    Function prototype definitions can usually be found
    in the manual page for the function or in a system
    include file (usually located under /usr/include).
    make: *** No targets specified and no makefile found. Stop.
    Synchronizing state of sockd.service with SysV service script with /lib/systemd/systemd-sysv-install.
    Executing: /lib/systemd/systemd-sysv-install enable sockd
    Dante Server Install Failed!

    1. 周可乐
      @周可乐

      有偿 qq 18701550252

      1. sunpma
        @周可乐

        用这个试试:https://sunpma.com/862.html

        1. 周可乐
          @sunpma

          gost -L user:dde24DF55fgreF@:58623 socks5://:1080 > /dev/null 2>&1 &是这样嘛?

          1. sunpma
            @周可乐

            对的

            1. 周可乐
              @sunpma

              telegram显示不可用

              1. sunpma
                @周可乐

                telegram用Socks5秒封,这是何必呢~~

                1. 周可乐
                  @sunpma

                  没被的办法了?用MTPROTO不行?

                  1. sunpma
                    @周可乐

                    https://sunpma.com/918.html

        2. 周可乐
          @sunpma

          1710708449 qq

          1. sunpma
            @周可乐

            TG:sunpma

  14. 求教

    这个程序老是自己崩掉。 有 进程守护的代码或者写法吗?

    1. sunpma
      @求教

      试试Gost吧:https://sunpma.com/862.html

  15. 阿龙

    只能添加用户。不能删除是什么鬼。centos7和debian9都是/etc/init.d/sockd: line 212: del_user: command not found

    1. sunpma
      @阿龙

      可以试试用Gost,更简单更方便 https://sunpma.com/862.html

  16. wuya

    用centos 7.5显示 Dante Server Install Failed! 怎么办

  17. wuya

    用了这个怎么内存越用越大,然后爆了 怎么解决??

    1. sunpma
      @wuya

      没出现过这种情况,这只是个流量转发,内存使用很低,不太可能爆内存,

  18. a2113087

    博主,为什么我服务器有20个IP,搭建起来却只有6个能通过?求解惑,有偿 qq 254093639

    1. sunpma
      @a2113087

      多IP我也没试过,不太清楚,你试试这个https://sunpma.com/862.html看行不行吧

      1. a2113087
        @sunpma

        博主,目前知道原因了。你提供的脚本非常好。问题是出在运营商那边。另外再请问一下重新设置账号密码那些的话需要 那个命令,或者配置文件的路径

      2. a2113087
        @sunpma

        刚刚试了一下,只有101.32.xx.xx 的IP段不通,其他段的ip都行。也不知道是什么原因

  19. luang87

    Dante Server Install Failed!

    脚本安装出现这个,我是Debian 10.3的版本,什么安装也不行。我看了这个脚本只是支持debian 8的吧,请问这个如何解决

    1. sunpma
      @luang87

      这个脚本高系统的不支持,你可以用这个https://sunpma.com/862.html

  20. minis

    跑完出現 Dante Server Install Failed!
    怎辦? 是腳本出問題了嗎?

    1. sunpma
      @minis

      试试这个:https://sunpma.com/862.html

    2. 治部少辅
      @minis

      我这里发现了类似的问题,在Dante Server Install Failed!提示信息下面有
      ```
      bash: line 331: /etc/init.d/sockd: No such file or directory
      ```
      说明这个文件没有创建成功,而在init.d路径下创建文件一般需要sudo权限。因此在执行安装监本的适合需要添加sudo:

      ```
      sudo bash install.sh --port=端口 --user=用户名 --passwd=密码
      ```

      如果仍然不能解决问题,查看一下日志文件:`/var/log/sockd.log`

    3. sunpma
      @minis

      没遇到过这问题,不太清楚~

      1. luang87
        @sunpma

        请问是不是不支持debian 10的版本啊?