📌 场景需求
RHEL8 主机 (192.168.100.139)可访问公网Windows 主机 (192.168.100.165)在同一内网(192.168.100.128/25),但不能访问公网目标:让 Windows 主机部分应用 通过 Dante 代理访问外网
🎯 部署目标
项目 内容 🎯 代理端口 13908(自定义) 🔒 安全限制 仅允许 192.168.100.128/25 网段访问代理服务 🌐 协议支持 TCP / UDP 全部转发 🧾 审计支持 启用日志输出 /var/log/danted.log
1️⃣ 安装 Dante Server
dnf install -y gcc make pam-devel
curl -LO https://www.inet.no/dante/files/dante-1.4.2.tar.gz
tar xzf dante-1.4.2.tar.gz
cd dante-1.4.2
./configure --prefix = /usr/local/dante
make -j$( nproc)
make install
📌 如果使用 EPEL 包:
dnf install dante-server -y
2️⃣ 创建配置文件 /usr/local/dante/etc/danted.conf
logoutput: /var/log/danted.log
internal: 192.168.100.139 port = 13908
external: 192.168.100.139
method: none
clientmethod: none
client pass {
from: 192.168.100.128/25 to: 0.0.0.0/0
log: connect disconnect error
}
client block {
from: 0.0.0.0/0 to: 0.0.0.0/0
log: connect error
}
pass {
from: 192.168.100.128/25 to: 0.0.0.0/0
protocol: tcp udp
log: connect disconnect error
}
block {
from: 0.0.0.0/0 to: 0.0.0.0/0
log: connect error
}
3️⃣ 创建 systemd 服务
cat > /etc/systemd/system/danted.service <<EOF
[Unit]
Description=Dante SOCKS5 Proxy Server
After=network.target
[Service]
ExecStart=/usr/local/dante/sbin/sockd -f /usr/local/dante/etc/danted.conf
ExecReload=/bin/kill -HUP \$MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reexec
systemctl daemon-reload
systemctl enable --now danted
4️⃣ 配置防火墙策略(允许特定网段访问)
firewall-cmd --permanent --add-rich-rule='
rule family="ipv4"
source address="192.168.100.128/25"
port protocol="tcp" port="13908" accept
'
firewall-cmd --permanent --remove-port=13908/tcp || true
firewall-cmd --reload
5️⃣ 验证部署效果
# 服务状态
systemctl status danted
# 监听端口
ss -ltnp | grep 13908
# 查看日志
tail -f /var/log/danted.log
📘 Windows Proxifier 示例配置(图形或导入)
项目 值 地址 192.168.100.139 端口 13908 协议 SOCKS5 验证方式 无(或用户名/密码,如配置)
🎯 Proxifier 规则举例
应用路径 动作 C:\Program Files\chrome\chrome.exe
使用代理 其他 不使用代理
🔄 回滚与卸载操作(如不再需要)
# 关闭服务
systemctl stop danted
systemctl disable danted
# 删除服务文件和配置
rm -rf /usr/local/dante /etc/systemd/system/danted.service
# 移除防火墙规则
firewall-cmd --permanent --remove-rich-rule='
rule family="ipv4"
source address="192.168.100.128/25"
port protocol="tcp" port="13908" accept
'
firewall-cmd --reload
🛡️ 风险与建议
风险点 说明 ❗️端口暴露 未限制 IP 时,SOCKS5 服务可能暴露公网 ❗️日志未轮转 /var/log/danted.log
需定期清理或配 logrotate ✅最小权限原则 默认配置已阻止所有非信任网段的访问 ✅兼容性 Dante 无需修改主机路由,透明性高
📚 参考资料