danted 使用

这个只是个人小实验,请勿用于生产环境

基本使用

可以这样配置部署:

# 安装
apt-get update
apt-get install dante-server
adduser --no-create-home --shell /usr/sbin/nologin dante-socks
# 启动代理
nohup  /usr/sbin/danted -f /etc/danted.conf&
# 本机验证转发
curl -x socks5h://127.0.0.1:10080 -m 5 http://httpbin.org/get | grep origin

/etc/danted.conf

internal: 0.0.0.0 port = 10080
external: eth0
errorlog: /mnt/danted/sockd.errlog
logoutput: /mnt/danted/sockd.log
user.notprivileged: dante-socks
clientmethod: none
socksmethod: none
client pass {
        from: 0.0.0.0/0 to: 0.0.0.0/0
        log: error connect disconnect iooperation
}
socks pass {
       from: 0.0.0.0/0 to: 0.0.0.0/0
       command: bindreply udpreply connect bind udpassociate
       log: error connect disconnect iooperation
}

扩展使用

阻断特定域名/IP的访问请求

#block incoming connections/packets from ftp.example.org 
socks block {
       from: 0.0.0.0/0 to: ftp.example.org
       command: bindreply udpreply
       log: error # connect disconnect iooperation
}

带宽管理

https://www.inet.no/dante/doc/1.4.x/config/bandwidth.html

socks pass {  
        from: 0.0.0.0/0 to: 0.0.0.0/0 port http
        command: connect
        log: error # connect disconnect iooperation
	bandwidth: 102400 #100kbps
}

重定向支持

https://www.inet.no/dante/doc/1.4.x/config/redirect.html

socks pass {
   from: 10.0.0.0/24 to: 0.0.0.0/0 port = http
   command: connect
   redirect to: squid.example.com port = 3128
}

源码下载

wget https://www.inet.no/dante/files/dante-1.4.4.tar.gz

github上有一个unofficial copy,tag打得比较全,可以方便查看修改历史。

https://github.com/notpeter/dante

端口转发

可以搭配frp端口转发使用。所以有三种转发端口的方式。

基于ssh的端口转发

ssh -L 0.0.0.0:10080:192.168.0.3:10080 [email protected]

基于frp + tls1.3

注意到frp的xtcp:https://gofrp.org/zh-cn/docs/features/xtcp/
使用的是tls1.3
细节见:https://gofrp.org/zh-cn/docs/features/common/network/network/
不需要额外配置,使用xtcp,默认就是tls1.3

基于frp + quic

frp支持 QUIC 协议
底层通信协议支持选择 QUIC 协议,底层采用 UDP 传输,解决了 TCP 上的一些问题,传输效率更高,连接延迟低。

# frps.toml
bindPort = 7000
# QUIC 绑定的是 UDP 端口,可以和 bindPort 一样
quicBindPort = 7000

使用感受

  1. 扩展使用上,对于修改修改网络流量转发的场景,还是挺有帮助的。
  2. 带宽管理上,对于企业内的使用,可以限制带宽,还可以。
  3. 效率比我以前用简单的pysocket高了不少,用起来比较丝滑。
  4. 端口转发效率上,用户感觉上,frp + tls1.3 > ssh > frp + quic
    感觉可能是frp的quic的实现/接入有bug?
    看frp代码依赖了这个版本:github.com/quic-go/quic-go v0.53.0

相关参考链接

  1. https://www.inet.no/dante/doc/1.4.x/config/server.html
  2. https://zhuanlan.zhihu.com/p/65094630
  3. https://www.finedb.cn/post/19
  4. https://gofrp.org/zh-cn/docs/

你可能感兴趣的:(danted)