Skip to content

Routing and freedom outbound ignore Fake DNS#696

Merged
Loyalsoldier merged 3 commits intov2fly:masterfrom
yuhan6665:fake
Feb 23, 2021
Merged

Routing and freedom outbound ignore Fake DNS#696
Loyalsoldier merged 3 commits intov2fly:masterfrom
yuhan6665:fake

Conversation

@yuhan6665
Copy link
Contributor

See discussion in #406.
Only internal is changed, there is no change in config. Fakedns still function as one of the normal item in dns object.

Turn off fake DNS for request sent from Routing and Freedom outbound.
Fake DNS now only apply to DNS outbound.
This is important for Android, where VPN service take over all system DNS
traffic and pass it to core.  "UseIp" option can be used in Freedom outbound
to avoid getting fake IP and fail connection
@Loyalsoldier
Copy link
Contributor

FakeDNS 不走路由,还有什么意义吗?🤔

@Loyalsoldier Loyalsoldier self-assigned this Feb 21, 2021
@yuhan6665
Copy link
Contributor Author

FakeDNS 不走路由,还有什么意义吗?🤔

是这样的,V2Ray 大体上要处理3类DNS,1是透明代理 或者 Android VPN 发出的DNS(在真正的连接开始之前的DNS),2是在内部路由时候选择非 asis ,并且没有配到domain而需要IP的DNS,3是选择了freedom outbound之后开始直连的DNS。
其实 Fake DNS 就是为1而生的,2 和 3 拿到fake IP 没有什么意义,只会产生问题。
56af71c 中我把其他都关掉了,只剩下1,具体配置和流程(用户仍然需要将前置DNS流量导入DNS outbound)是不变的

@darren
Copy link

darren commented Feb 22, 2021

在启用fakedns的情况下,会导致outbounds中以域名作为地址的vmess也走fakeip,例如:

 "outbounds": [
    {
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "使用域名example.com",
            "port": 53,
            "users": [
            ]
          },
 ...
  "dns": {
    "servers": [
      {
        "address": "https+local://223.5.5.5/dns-query",
        "domains": [
          "geosite:cn"
        ],
        "expectIPs": [
          "geoip:cn"
        ]
      },
      "fakedns",
      "https+local://1.1.1.1/dns-query",
    ]
  },

结果连接example.com的时候用的是ip 240.0.0.0, 导致失败的连接,这个pr有考虑这个问题吗?

@yuhan6665
Copy link
Contributor Author

@darren it is possible fixed by this pr. Do you have log when you see this issue? I need to take a look at the log.

@darren
Copy link

darren commented Feb 22, 2021

@yuhan6665
可能是我的配置问题,想用一个最简的配置,结果无法复现,如果我能定位到有问题的配置,我新开一个issue吧。

@Loyalsoldier
Copy link
Contributor

Loyalsoldier commented Feb 22, 2021

是这样的,V2Ray 大体上要处理3类DNS,1是透明代理 或者 Android VPN 发出的DNS(在真正的连接开始之前的DNS),2是在内部路由时候选择非 asis ,并且没有配到domain而需要IP的DNS,3是选择了freedom outbound之后开始直连的DNS。
其实 Fake DNS 就是为1而生的,2 和 3 拿到fake IP 没有什么意义,只会产生问题。
56af71c 中我把其他都关掉了,只剩下1,具体配置和流程(用户仍然需要将前置DNS流量导入DNS outbound)是不变的

我不太熟悉透明代理的使用场景,这种情况下,是否需要在 func (s *DNS) sortClients(domain string) []*Client 函数中把 FakeDNS 排在第一位?🤔

@xiaokangwang
Copy link
Contributor

这个PR在原理上没有什么问题。如果没有这个设置的话,那么就会需要在dns的部分单独设置白名单才能让相关的域名不走fakedns。

@yuhan6665
Copy link
Contributor Author

是这样的,V2Ray 大体上要处理3类DNS,1是透明代理 或者 Android VPN 发出的DNS(在真正的连接开始之前的DNS),2是在内部路由时候选择非 asis ,并且没有配到domain而需要IP的DNS,3是选择了freedom outbound之后开始直连的DNS。
其实 Fake DNS 就是为1而生的,2 和 3 拿到fake IP 没有什么意义,只会产生问题。
56af71c 中我把其他都关掉了,只剩下1,具体配置和流程(用户仍然需要将前置DNS流量导入DNS outbound)是不变的

我不太熟悉透明代理的使用场景,这种情况下,是否需要在 func (s *DNS) sortClients(domain string) []*Client 函数中把 FakeDNS 排在第一位?🤔

确实不放第一个有可能不启用
曾经某个版本Fakedns 是个开关,开的时候会无条件启用,后来 xiaokangwang 大佬改成 DNS 其中一项,我理解是为了增加很多灵活的配置方法,给某些域名开或关,所以不用改用户定义的顺序

@rurirei
Copy link
Contributor

rurirei commented Feb 22, 2021

在启用fakedns的情况下,会导致outbounds中以域名作为地址的vmess也走fakeip,例如:

 "outbounds": [
    {
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "使用域名example.com",
            "port": 53,
            "users": [
            ]
          },
 ...
  "dns": {
    "servers": [
      {
        "address": "https+local://223.5.5.5/dns-query",
        "domains": [
          "geosite:cn"
        ],
        "expectIPs": [
          "geoip:cn"
        ]
      },
      "fakedns",
      "https+local://1.1.1.1/dns-query",
    ]
  },

结果连接example.com的时候用的是ip 240.0.0.0, 导致失败的连接,这个pr有考虑这个问题吗?

Ref: rurirei/Kitsunebi#6

"dns": { "servers": [ "fakedns", "8.8.8.8" ] },
"outbounds": { "protocol": "dns" },
"routing": [ { "network": "udp", "port": "53", "outboundTag": "dns" } ]

@rurirei
Copy link
Contributor

rurirei commented Feb 22, 2021

@yuhan6665

2是在内部路由时候选择非 asis ,并且没有配到domain而需要IP的DNS,3是选择了freedom outbound之后开始直连的DNS

non-AsIs dns requests need also FakeDns to effectively parsed, as those are request parsed inside v2ray. as my point only AsIs requests could not be into FakeDns.

@Loyalsoldier
Copy link
Contributor

Merge for now. New PRs for other features are welcomed.

@Loyalsoldier Loyalsoldier merged commit afb8385 into v2fly:master Feb 23, 2021
@yuhan6665
Copy link
Contributor Author

@yuhan6665

2是在内部路由时候选择非 asis ,并且没有配到domain而需要IP的DNS,3是选择了freedom outbound之后开始直连的DNS

non-AsIs dns requests need also FakeDns to effectively parsed, as those are request parsed inside v2ray. as my point only AsIs requests could not be into FakeDns.

Setting AsIs in Freedom outbound is probably fine in case of 透明代理 and is hard to fix on Android.

On the other hand, no matter what mode you set, I don't see value getting Fake IP at freedom outbound. It can only cause trouble.

@bhoppi
Copy link
Contributor

bhoppi commented Mar 17, 2021

当前的配置结构还是有些问题,详见讨论 #789
而且大佬曾经提出的解决方案( #406 (comment) )几乎与我不谋而合,不知为何没有按照这个方案进行实现?

@rurirei
Copy link
Contributor

rurirei commented May 8, 2021

should dns server of v2ray (DoH) meet fakedns as well, is it? @yuhan6665

@yuhan6665
Copy link
Contributor Author

@rurirei I understand on Android DOH format should work without issue. DOHL will not work unless you list the DNS server and ip in the hosts section.

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

Successfully merging this pull request may close these issues.

6 participants