用 Dante 搭建 SOCKS5 代理

工作上用到 socks5,难免需要自己的环境调试。同事介绍说一般用 Dante,就用这个。

官方下载:https://www.inet.no/dante/download.html

不过我装的时候莫名上不去,就从 https://fossies.org/linux/misc/dante-1.4.2.tar.gz 下载,在服务器上操作如下

1. wget https://fossies.org/linux/misc/dante-1.4.2.tar.gz

2. tar -xvf dante-1.4.2.tar.gz

3. cd dante-1.4.2

4. ./configure

5. make

6. make install

可能会有些错误,需要完善环境,网上都可以查到。安装完用 sockd 启动,会提示你配置文件错误

7. 创建配置文件 sudo vim /etc/sockd.conf,配置如下:

logoutput:/var/log/sockd/sockd.log
internal: eth0 port = 1080
external: eth0 ## <-- 公网 IP
#clientmethod: none
socksmethod: username
#ser.privileged: root
#ser.unprivileged: nobody

method: username
user.privileged: root

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

client block {
    from: 0.0.0.0/0 to: 127.0.0.0/8
    log: error
}

socks pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    command: bind connect udpassociate
}

socks pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    command: bindreply udpreply
    log: error
}

socks block {
    from: 0.0.0.0/0 to: 127.0.0.0/8
    command: bind connect udpassociate
    log: connect error
}

8. mkdir /var/log/sockd

9. 启动 sudo /usr/local/sbin/sockd

10. 添加系统账号,即是 socks5 账号
useradd -M -s /usr/sbin/nologin -p $(openssl passwd -1 {PASSWORD}) {USER}

11. 用客户端登陆试试吧

Wish me luck!