![Dante sockd 无法通过多个虚拟 IP 转发流量](https://linux22.com/image/658387/Dante%20sockd%20%E6%97%A0%E6%B3%95%E9%80%9A%E8%BF%87%E5%A4%9A%E4%B8%AA%E8%99%9A%E6%8B%9F%20IP%20%E8%BD%AC%E5%8F%91%E6%B5%81%E9%87%8F.png)
我已经配置了 Dante sockd 以通过多个 IP 接口转发流量。配置基本如下:
logoutput: /var/log/sockd.log
debug: 1
socksmethod: username none
internal: eth0 port = 60000
external: eth0
internal: eth0:0 port = 60000
external: eth0:0
internal: eth0:1 port = 60000
external: eth0:1
internal: eth0:2 port = 60000
external: eth0:2
...
external.rotation: same-same
client pass {
from: 0.0.0.0/0 port 1-65535 to: 0.0.0.0/0
socksmethod: username
}
socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
socksmethod: username
protocol: tcp udp
}
禁用“external.rotation = same.same”后,流量将通过服务器,但仅从一个地址发出。启用后,我使用 curl 时收到以下错误:
curl: (7) Can't complete SOCKS5 connection to x.x.x.x:80. (3)
日志中出现以下错误:
May 15 07:38:38 (1431689918.007569) sockd[4887]: info: block(1): tcp/accept ]: x.x.x.x.56066 y.y.y.y.60000: request was not performed due to error: could not get address to use on external side: using external.rotation = same-same, local address x.x.x.x was selected for forwarding from our local client x.x.x.x.56066 to target z.z.z.z.80, but that local address is not set on our external interface(s). Configuration error in /etc/sockd.conf?
xxxx 是我的 IP 地址,yyyy 是服务器端地址,zzzz 是目标地址。
这表明服务器希望伪装成我的地址但尚未配置,这是正确的,因为我希望流量被视为来自 yyyy 地址,而该地址有超过一百个可供选择。
我在文档中找不到与我看到的错误相匹配的任何内容,我怀疑需要某种循环配置,但我也找不到。有人用这种方法成功了吗?
答案1
以下操作对我在 CentOS 6.x 64 位上的 Dante 1.4.2 上有效,尽管我没有使用身份验证,因为我通过 SSH 隧道访问 Dante(我的服务器的 IP 是 1.1.1.1、2.2.2.2 和 3.3.3.3):
logoutput: syslog stdout stderr /var/log/sockd.log
internal: eth0:0 port = 1080
internal: eth0:1 port = 1080
internal: eth0:2 port = 1080
external: eth0:0
external: eth0:1
external: eth0:2
external.rotation: same-same
user.privileged: root
user.unprivileged: sockd
#user.libwrap: sockd
clientmethod: none
socksmethod: none
client pass {
from: 1.1.1.1/32 to: 0.0.0.0/0
log: error # connect disconnect
}
client pass {
from: 2.2.2.2/32 to: 0.0.0.0/0
log: error # connect disconnect
}
client pass {
from: 3.3.3.3/32 to: 0.0.0.0/0
log: error # connect disconnect
}
socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
command: bind connect udpassociate
log: error # connect disconnect iooperation
}
socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
command: bindreply udpreply
log: error # connect disconnect iooperation
}
然后从我的客户端机器创建三个本地隧道:
ssh -L 10801:1.1.1.1:1080 -L 10802:2.2.2.2:1080 -L 10803:3.3.3.3:1080 [email protected]
我认为设置过程中遇到的大多数问题都是权限问题(客户端密码和 socks 密码)。
如果您仍然遇到问题,您可以尝试 Dante 的替代方案:3Proxy。
您可以按照以下方式配置 3proxy:
nserver 8.8.8.8
auth none
daemon
socks -p1080 -i1.1.1.1 -e1.1.1.1
socks -p1080 -i2.2.2.2 -e2.2.2.2
socks -p1080 -i3.3.3.3 -e3.3.3.3
pidfile /var/run/3proxy.pid
log /dev/null
希望这可以帮助。
答案2
您是否尝试过为您的操作系统启用 IP 转发?
sysctl -w net.ipv4.ip_forward=1
或者
echo 1 > /proc/sys/net/ipv4/ip_forward
更多信息 @http://linuxconfig.org/how-to-turn-on-off-ip-forwarding-in-linux