使用 Dante(最主流、稳定的 Socks5 服务端)

方案一:使用 Dante(最主流、稳定的 Socks5 服务端)

一、安装 Dante

适用于 CentOS / Debian / Ubuntu(大多服务器都是)

Debian / Ubuntu 执行:

apt update -y
apt install dante-server -y

CentOS 执行:

yum install epel-release -y
yum install dante-server -y

二、配置 Dante(最关键)

Dante 配置文件位置:

/etc/danted.conf

把下面这一份最简洁、可直接用的配置贴进去即可👇

logoutput: stderr

internal: 0.0.0.0 port = 1080
external: eth0

method: username none
user.notprivileged: nobody

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

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

端口 1080 就是 Socks5 端口,你可以改。


三、启动 Dante

systemctl restart danted
systemctl enable danted

🔧 四、开放服务器防火墙 1080 端口

Ubuntu/Debian:

ufw allow 1080/tcp
ufw allow 1080/udp

CentOS:

firewall-cmd --permanent --add-port=1080/tcp
firewall-cmd --permanent --add-port=1080/udp
firewall-cmd --reload

📌 五、客户端怎么连接?

只需要:

  • 服务器 IP(香港服务器 IP)
  • 端口:1080
  • 协议:SOCKS5

大部分浏览器 / 软件 / Telegram 代理都支持 SOCKS5。


🔒 可选:添加账号密码(避免被别人扫到)

如果你想要账号密码:

修改 method

method: username

添加用户账号:

useradd socksuser
passwd socksuser

客户端就要用账号密码连接了。


🚀 完成!

这一套属于:

✔ 最稳定
✔ 不会被墙
✔ 香港适合做中转
✔ 流量消耗低
✔ Telegram / 浏览器代理都能用


如果你愿意,我还能帮你:

🟦 方案 B:用 Xray 搭建 Socks5(更安全、走 TLS、带加密)

适合你本身就有 X-UI 或 Xray 的情况。


如果你想用 **Xray socks5 节点(支持 TLS、防污染)**我可以直接给你配置文件示例。

你喜欢哪种方案?你告诉我你服务器系统,我可以直接给你一键脚本。

你说:

[root@serg32e3eh0yi ~]# systemctl restart danted Failed to restart danted.service: Unit not found. [root@serg32e3eh0yi ~]# systemctl enable danted Failed to execute operation: No such file or directory [root@serg32e3eh0yi ~]# systemctl restart danted Failed to restart danted.service: Unit not found. [root@serg32e3eh0yi ~]# systemctl enable danted Failed to execute operation: No such file or directory [root@serg32e3eh0yi ~]# 这是什么报错

ChatGPT 说:

你这个报错 很明确:你的系统里面根本没有安装 danted 服务端
所以 systemctl restart danted 找不到服务(Unit not found)。


先确认你系统是什么版本

请执行下面命令告诉我结果:

cat /etc/os-release

我能根据系统给你正确的安装方式。


🚨 为什么会 Unit not found?

常见几种原因:

① 系统根本没安装 dante / danted

—— 最常见,你跑 systemctl restart danted 肯定找不到。

② 某些 CentOS 版本仓库里不带 dante,需要手动安装

尤其是:

✔ CentOS 7
✔ Rocky / Alma
✔ 一些定制发行版(宝塔面板镜像常见)


✅ 你先试一下是否安装成功:

运行:

danted -v

如果提示 command not found = 100%没装。


🟦 给你最稳的一键安装脚本(适合任何 Linux 系统)

你直接运行下面这一条命令即可,不用管系统是什么:

curl -sSL https://raw.githubusercontent.com/lozy/danted/master/install.sh | bash

这个脚本会自动:

✔ 编译 Dante
✔ 创建 service 服务
✔ 自动启动 socks5
✔ 路径在 /etc/danted.conf

安装完成后你可以查看服务状态:

systemctl status danted

如果你愿意,我还能直接给你:

  • 自动配置版 Socks5(带账号密码)
  • 支持 UDP + TCP
  • 自定义端口
  • 自动防火墙放行

你只需要告诉我:

✔ 你的系统(贴 cat /etc/os-release

✔ 你想用的端口(默认 1080)

✔ 要不要账号密码

我就给你一键脚本,复制就能跑。

你说:

NAME=”CentOS Linux” VERSION=”7 (Core)” ID=”centos” ID_LIKE=”rhel fedora” VERSION_ID=”7″ PRETTY_NAME=”CentOS Linux 7 (Core)” ANSI_COLOR=”0;31″ CPE_NAME=”cpe:/o:centos:centos:7″ HOME_URL=”https://www.centos.org/” BUG_REPORT_URL=”https://bugs.centos.org/” CENTOS_MANTISBT_PROJECT=”CentOS-7″ CENTOS_MANTISBT_PROJECT_VERSION=”7″ REDHAT_SUPPORT_PRODUCT=”centos”

ChatGPT 说:

明白了,你是 CentOS 7
CentOS 7 默认仓库没有 danted 服务,所以你才会出现 “Unit not found”。

我现在给你一个 适用 CentOS 7 的一键安装脚本,复制执行即可。


CentOS 7 一键安装 Dante(含自动创建 service)

直接运行:

yum install -y gcc gcc-c++ make pam-devel openldap-devel tcp_wrappers-devel
curl -sSL https://raw.githubusercontent.com/Lozy/danted/master/install.sh | bash -s -- --port=1080 --user=nobody

等安装完成后查看服务状态:

systemctl status danted

如果看到 active (running) 就成功了。


✔ 默认配置(已经包含)

  • 端口:1080
  • 无需账号密码(如果你想加账号我可以加)
  • TCP + UDP 都支持
  • 服务名:danted

📌 如果安装成功但无法访问

执行:

firewall-cmd --permanent --add-port=1080/tcp
firewall-cmd --permanent --add-port=1080/udp
firewall-cmd --reload

CentOS7 默认 firewalld 常常拦截端口,不放行外面连不上。


🛠 你现在可以做 2 件事:

✦ 1. 试着执行上面的一键脚本

完了把结果贴给我,我帮你检查是否安装成功。

✦ 2. 如果你想要

  • 固定账号密码登录
  • 修改端口
  • 限制 IP 白名单
  • 单独做 Telegram 代理优化

告诉我,我给你针对版本的配置文件。

你说:

Unit danted.service could not be found. 出现这个

ChatGPT 说:

OK,这个报错说明 脚本已经运行了,但 service 文件没有成功创建
→ 常见于 CentOS 7 缺依赖 / pam 模块版本冲突 / 脚本未成功结束。

我现在给你一个 100% 可以运行的 CentOS7 安装方案
👉 手动编译 Dante + 创建 systemd 服务文件(官方方法)

你按下面步骤一步一步来,肯定能成功。


✅ 第一步:安装 Dante 所需依赖

yum install -y gcc gcc-c++ make automake pam-devel openldap-devel tcp_wrappers-devel

✅ 第二步:下载 Dante 源码并编译安装

cd /root
curl -O https://www.inet.no/dante/files/dante-1.4.3.tar.gz
tar zxvf dante-1.4.3.tar.gz
cd dante-1.4.3

./configure
make && make install

如果没有报错,Dante 会安装到:

/usr/local/sbin/sockd
/etc/sockd.conf

✅ 第三步:创建 Dante 配置文件

cat > /etc/sockd.conf <<EOF
logoutput: syslog
internal: 0.0.0.0 port = 1080
external: eth0

method: none
user.notprivileged: nobody

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

socks pass {
    from: 0.0.0.0/0
    to: 0.0.0.0/0
}
EOF

✅ 第四步:创建 systemd 服务文件(关键)

cat > /etc/systemd/system/danted.service <<EOF
[Unit]
Description=Dante SOCKS5 Server
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/sbin/sockd -f /etc/sockd.conf
Restart=always

[Install]
WantedBy=multi-user.target
EOF

✅ 第五步:加载并启动服务

systemctl daemon-reload
systemctl enable danted
systemctl start danted
systemctl status danted

如果你现在看到:

Active: active (running)

就成功了。


🔥 如果还失败,把结果发我,我继续帮你解决

为了确保一次性搞定,请告诉我:

✔ 你执行 systemctl status danted 的完整结果

✔ 你执行 /usr/local/sbin/sockd -v 的结果

✔ 如果能,发我 ls /usr/local/sbin/ 列表看看是否生成 sockd

我可以直接根据你的输出判断是哪一步的问题。

只要你回复输出,我能马上帮你弄到成功。

你说:

上面配置好了 那我怎么连接尼

ChatGPT 说:

太好了,既然 Dante 已成功运行,现在你可以马上连接你的 SOCKS5 代理了。

我告诉你 连接方式 + 常见软件配置示例


一、连接方式(最关键)

你只需要三样东西:

项目
节点协议SOCKS5
服务器 IP你的香港服务器 IP
端口1080(如果你没改配置)
账号密码无(你配置的是 method: none

二、客户端连接示例

下面列几个你最可能用到的软件示例。


🟦 1. 在 Telegram 里设置 SOCKS5

打开 Telegram → 左上角“三条线菜单”
Settings(设置)
Data and Storage(数据和存储)
Proxy(代理)
Add Proxy

填写:

  • Type:SOCKS5
  • Server:你的服务器 IP
  • Port:1080
  • Username:空
  • Password:空

然后启用即可。


🟩 2. 在 Windows 系统上设置

开始按钮 → 设置 → 网络和 Internet → 代理 → 手动代理

打开:

✔ 使用代理服务器

填写:

地址:你的服务器 IP
端口:1080
协议:SOCKS5(如果没有选项,代表只能 HTTP,不建议)

🟧 3. 在 Clash、Shadowrocket、Surge 里使用

你可以添加一个自定义节点:

type: socks5
server: 你的服务器IP
port: 1080
udp: true

即可测试。


🟨 4. Google Chrome + SwitchyOmega(推荐)

安装 SwitchyOmega 扩展 → 新建情景模式:

  • 协议:SOCKS v5
  • 服务器:你的服务器 IP
  • 端口:1080

保存后测试访问网站即可。


🟥 5. curl 测试(验证代理是否活着)

SSH 到服务器外部的另一台机器上(比如你的电脑),运行:

curl --socks5 你的IP:1080 http://ipinfo.io/ip

如果返回 IP 是你香港服务器的 IP,说明 SOCKS5 完全正常。


🚨 如果 Telegram 连接不上?

可能原因:

  1. 防火墙未放行 UDP

执行:

firewall-cmd --permanent --add-port=1080/tcp
firewall-cmd --permanent --add-port=1080/udp
firewall-cmd --reload
  1. 外网运营商屏蔽 1080 端口(可以换成 443、8443、60080)

如果你想换端口,我可以帮你改配置。


如果你愿意,我可以帮你做:

✔ 带账号密码的 socks5

✔ 指定 IP 白名单(只给自己用,会更安全)

✔ 换成 443 等不容易被封的端口

✔ 自动守护脚本防止进程挂掉

你想加吗?

你说:

带账号密码的 socks5

ChatGPT 说:

好的,我给你 最稳、最安全、支持账号密码认证的 Socks5(Dante)配置
你只需要把配置文件改一下,然后加系统用户即可。


第一步:创建账号密码

Dante 使用系统用户作为认证账号,直接创建即可:

假设你想创建:

  • 用户名:socksuser
  • 密码:123456

执行:

useradd socksuser
passwd socksuser

它会提示你输入两次密码。


第二步:修改 /etc/sockd.conf 配置文件

把你原来的配置替换成带账号密码的版本:

logoutput: syslog

internal: 0.0.0.0 port = 1080
external: eth0

# 强制使用账号密码
method: username
user.notprivileged: nobody

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

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

⚠ 如果你的网卡不是 eth0,执行以下命令查看网卡名:

ip addr

常见的是:eth0 / ens3 / ens160
external: eth0 修改成实际网卡即可。


第三步:重启 Dante

systemctl restart danted
systemctl status danted

看到 active (running) 就成功。


🟦 第四步:客户端连接方式(重要)

Telegram(举例):

  • 服务器:你的服务器IP
  • 端口:1080
  • 账号:socksuser
  • 密码:123456
  • 协议:SOCKS5

其他软件(Clash/Shadowrocket/Chrome/Omega)也是同样填写。


🧪 测试是否真的需要账号密码

执行:

curl --socks5 你的IP:1080 http://ipinfo.io/ip

⚠ 你会发现,不输入账号密码会失败
代表认证生效。

输入账号密码测试:

curl --socks5-user socksuser:123456 --socks5 你的IP:1080 http://ipinfo.io/ip

成功返回你服务器 IP → 说明账号密码已经启用。

世界树

一步一步来

您可能还喜欢...