• 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

     https://raw.github.com/Lozy/danted/master/install.sh

    1. #!/bin/bash
    2. #
    3. # Dante Socks5 Server AutoInstall
    4. # -- Owner: https://www.inet.no/dante
    5. # -- Provider: https://sockd.info
    6. # -- Author: Lozy
    7. #
    8. # Check if user is root
    9. if [ $(id -u) != "0" ]; then
    10. echo "Error: You must be root to run this script, please use root to install"
    11. exit 1
    12. fi
    13. REQUEST_SERVER="https://raw.github.com/Lozy/danted/master"
    14. SCRIPT_SERVER="https://public.sockd.info"
    15. SYSTEM_RECOGNIZE=""
    16. [ "$1" == "--no-github" ] && REQUEST_SERVER=${SCRIPT_SERVER}
    17. if [ -s "/etc/os-release" ];then
    18. os_name=$(sed -n 's/PRETTY_NAME="\(.*\)"/\1/p' /etc/os-release)
    19. if [ -n "$(echo ${os_name} | grep -Ei 'Debian|Ubuntu' )" ];then
    20. printf "Current OS: %s\n" "${os_name}"
    21. SYSTEM_RECOGNIZE="debian"
    22. elif [ -n "$(echo ${os_name} | grep -Ei 'CentOS')" ];then
    23. printf "Current OS: %s\n" "${os_name}"
    24. SYSTEM_RECOGNIZE="centos"
    25. else
    26. printf "Current OS: %s is not support.\n" "${os_name}"
    27. fi
    28. elif [ -s "/etc/issue" ];then
    29. if [ -n "$(grep -Ei 'CentOS' /etc/issue)" ];then
    30. printf "Current OS: %s\n" "$(grep -Ei 'CentOS' /etc/issue)"
    31. SYSTEM_RECOGNIZE="centos"
    32. else
    33. printf "+++++++++++++++++++++++\n"
    34. cat /etc/issue
    35. printf "+++++++++++++++++++++++\n"
    36. printf "[Error] Current OS: is not available to support.\n"
    37. fi
    38. else
    39. printf "[Error] (/etc/os-release) OR (/etc/issue) not exist!\n"
    40. printf "[Error] Current OS: is not available to support.\n"
    41. fi
    42. if [ -n "$SYSTEM_RECOGNIZE" ];then
    43. wget -qO- --no-check-certificate ${REQUEST_SERVER}/install_${SYSTEM_RECOGNIZE}.sh | \
    44. bash -s -- $* | tee /tmp/danted_install.log
    45. else
    46. printf "[Error] Installing terminated"
    47. exit 1
    48. fi
    49. exit 0

    安装脚本

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

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

    使用

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

    vi /etc/danted/sockd.conf
    1. 修改以下代码,改成你需要设置的白名单IP或IP段即可,然后重启使其生效;
    2. client pass {
    3. from: 0.0.0.0/0 to: 0.0.0.0/0
    4. }

    卸载

    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

    使用Proxifier工具代理 

  • 相关阅读:
    Could not load the Qt platform plugin “xcb“ in
    【Android面试八股文】讲一讲StackOverFlow和OOM的区别?栈和堆分别存储的是什么?
    【408篇】C语言笔记-第九章(数据结构概述)
    安装Ubuntu提示:系统找不到指定的文件。
    【深入学习Redis丨第二篇】Redis集群部署详解
    5G网络助力智慧文旅发展:实现旅游资源的优化配置与高效利用
    社交媒体商业禁令冲击:TikTok如何应对印尼政策变化?
    WEBPACK基础配置【总结】
    HTML5+CSS3小实例:纯CSS实现彩虹倒映水面的唯美背景
    Warning: `ReactDOMTestUtils.act` is deprecated in favor of `React.act`.
  • 原文地址:https://blog.csdn.net/qq_15371293/article/details/130853660