"autoOutboundsInterface" 为 "127.0.0.1" 配置了 错误的 的网卡 (network interface)
### 完整性要求
- [x] 我读完了 issue 模板中的所有注释,确保填写符合要求。
- [x] 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
- [x] 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。
- [x] 我搜索了 issues, 没有发现已提出的类似问题。
- [x] 问题在 Release 最新的版本上可以成功复现
### 描述
客户端使用 TUN 作为 inbound,并配置 inbound->tun->settings->autoOutboundsInterface 时,address 为 127.0.0.1 的 outbound/出站 会无法建立连接。
此时,如果手动配置该 outbound/出站 的 "sockopt"->"interface": "Loopback Pseudo-Interface 1",则该出站可以正常建立连接。
.\xray.exe version
Xray 26.6.1 (Xray, Penetrates Everything.) 94ffd50 (go1.26.3 windows/amd64)
A unified platform for anti-censorship.
猜测原因:对大部分 outbound/出站 而言,autoOutboundsInterface 指定了 正确的 提供互联网连接的网卡,比如 “Wi-Fi”/“ens33”。但是 **_对于 address 为 127.0.0.1 的 outbound/出站,autoOutboundsInterface 也指定了用于 互联网连接的网卡 !这是错误的!_**,因为 127.0.0.1 应该路由到 "lo" (linux) / "Loopback Pseudo-Interface 1" (windows) 。
建议修复:对于 address 为 127.0.0.1 / ::1 / localhost 的 outbound/出站,autoOutboundsInterface 不应该指定网卡,使用系统自带的路由表就好了。
延申考虑:是否检查系统路由表,对于路由表中已经有的 route,mask 小于 /24(ipv4) 或 小于 /64(ipv6),都视作尊重系统路由表。此时如果 outbound/出站 的 address 与之重合,则 autoOutboundsInterface 对该 outbound/出站 不指定 网卡/interface。
### 重现方式
配置 socks 出站,address 为 127.0.0.1,同时配置 tun 出站 + autoOutboundsInterface: auto。
则该 socks 出站 无法建立连接。
### 客户端配置
Bug outbound:
<details><pre><code>
{
"protocol": "socks",
"settings": {
"address": "127.0.0.1",
"port": 59091
}
}
</code></pre></details>
Working outbound:
<details><pre><code>
{
"protocol": "socks",
"settings": {
"address": "127.0.0.1",
"port": 59091
},
"streamSettings": {
"sockopt": {
"interface": "Loopback Pseudo-Interface 1"
}
}
}
</code></pre></details>
### 服务端配置
NONE
### 客户端日志
2026/06/05 01:13:38.021265 [Info] transport/internet/tcp: dialing TCP to tcp:127.0.0.1:59091
2026/06/05 01:13:38.423633 [Info] app/proxyman/outbound: app/proxyman/outbound: failed to process outbound traffic > proxy/socks: failed to find an available destination > common/retry: [dial tcp 127.0.0.1:59091: connectex: The requested address is not valid in its context.] > common/retry: all retry attempts failed
### 服务端日志
NONE
4 条评论