Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于 "address": " 域名 " 时,outbound proxy 无法链接的解决方案 #12

Closed
CerteKim opened this issue Mar 5, 2021 · 7 comments

Comments

@CerteKim
Copy link
Collaborator

CerteKim commented Mar 5, 2021

问题原因

由于 Xray 引用的某官方包的原因,Xray 查询 域名 的 ip地址 时,会先读取 hostresolv.conf

在 Android 系统上,host 文件只包含 localhost,而且 resolv.conf 不存在。

于是 Xray 会向 本地 DNS 服务器 查询,即 127.0.0.1:53,但 Android 上不存在本地 DNS 服务器(只有开启了热点时,才会启用 dnsmasq 并监听 53 端口)。

导致无法查询域名所在服务器 ip,表现为无法连接。

解决方案

  • 修改配置文件,使用 ip 地址。

    • 但此方法对 DDNS 不友好。
  • 使用 Xray 自己监听 53 端口,启用 DNS 模块并在 routing 中将 DNS 请求全部由 Freedom 发出。

    • 但这样会导致 dnsmasq 无法启动,在某些 Android ROM 中会导致无法开启热点。
  • 使用 CGO_ENABLED=1 flag 在 Go 编译时启用 CGO,此时会使 Xray 查询 DNS 记录时,通过 Android 的 glibc 发出请求,可以读取 props 中 的 [net.dns*]

    • 理论上“无痛”。
  • 等待 @JimhHanPR 合并。

    • 配置文件需要考虑防止 DNS 查询回环。
  • 等待 Golang 官方自己修复。

    • 官方在这个地方,是只鸽子。

结论

Xray-core 1.3.1 中,已经加入一个新的功能:(可选)使用 内置 DNS 模块 来查询 DNS。

在本模块后续的版本附带的配置文件中将默认启用这个功能。

也就是说 proxy.json 除保留 "tag": "proxy" 外,还要在 streamSettings 中保留

"sockopt": {
    "domainStrategy": "UseIP"
}
@CerteKim CerteKim pinned this issue Mar 5, 2021
@csy19960309
Copy link

csy19960309 commented May 12, 2021

还有个方法是修改/system/etc/hosts.

BTW方法

"sockopt": {
    "domainStrategy": "UseIP"
}

有个问题是急剧增加资源占用,表现为耗电猛增。

@CerteKim
Copy link
Collaborator Author

@csy19960309 确实可以通过修改 hosts 来解决。

耗电猛增很有可能是 DNS 请求回环或者堵塞,使用这个方法需要较高的水平。

正在考虑更好的方案,或者等新的 DNS服务器 实现(咕咕咕

@xtccc
Copy link

xtccc commented Aug 28, 2021

我折腾了半个小时,就是为了解决[::1]:53 的DNS 问题,
还是直接把 "address": " 域名 " 变成 "address": " vps ip " 解决了

@wfniub
Copy link

wfniub commented Sep 16, 2021

Andy:
[Info]: Starting xray service.
[Error]: Start xray service Failed.

Andy:
[Info]: Starting xray service.
grep: /proc/12125/cmdline: No such file or directory
[Error]: Start xray service Failed.
inotifyd: exec /data/adb/xray/scripts/xray.inotify: Permission denied
inotifyd: exec /data/adb/xray/scripts/xray.inotify: Permission denied
inotifyd: exec /data/adb/xray/scripts/xray.inotify: Permission denied
inotifyd: exec /data/adb/xray/scripts/xray.inotify: Permission denied
inotifyd: exec /data/adb/xray/scripts/xray.inotify: Permission denied
inotifyd: exec /data/adb/xray/scripts/xray.inotify: Permission denied
inotifyd: exec /data/adb/xray/scripts/xray.inotify: Permission denied

@wfniub
Copy link

wfniub commented Sep 16, 2021

这是怎么回事,哪位大佬可以指点迷津

@CerteKim CerteKim unpinned this issue Mar 12, 2022
@JimmyPOon1
Copy link

你好 我也遇见这个问题了 现在可以解决了吗

@soundghost
Copy link

请问error.log日志里出现这样的信息,也是因为dns的原因么?

[Error] app/dns: failed to retrieve response for 此处为我的proxy域名. > Post "https://1.1.1.1/dns-query": context canceled

但是我查看了配置文件里是有

"sockopt": {
    "domainStrategy": "UseIP"
}

这段代码的,并且诡异的是,当我使用流量时打不开国外网站,但是我使用WiFi却可以。

请问这是怎么回事呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants