XTLS / Xray-core

Xray, Penetrates Everything. Also the best v2ray-core, with XTLS support. Fully compatible configuration.
https://t.me/projectXray
Mozilla Public License 2.0
25.62k stars 3.96k forks source link

透明代理下似乎未能如期将 DNS 请求路由到 localhost #1265

Closed Aniark closed 7 months ago

Aniark commented 2 years ago

使用场景:Android 手机,透明代理由 Magisk 模块 Xray4Magisk 提供

以下配置文件为了便于说明做了一些简化

DNS 配置,!cn 域名使用 fakedns,cn 则为 localhost "dns": { "servers": [ { "address": "fakedns", "domains": ["geosite:geolocation-!cn"] }, { "address": "localhost", "domains": ["geosite:cn", "geosite:geolocation-cn"] } ], "tag": "dns", "queryStrategy": "UseIP" }

预期情况:cn 域名将由 localhost 解析 实际情况:cn 域名一律无法正常解析,只有 !cn 域名正常解析

经测试,该现象从版本 1.5.0 到当前的 Latest 1.6.0 都存在,但是 1.4.0 却没有这个没有这个问题

chika0801 commented 2 years ago

https://www.v2fly.org/config/fakedns.html#%E4%B8%8E-dns-%E5%88%86%E6%B5%81%E5%85%B1%E5%AD%98

参考以下这个文档

当使用 DNS 分流时,为了让 fakedns 拥有高优先级,需要增加与其他类型 DNS 相同的 domains 配置。

Aniark commented 2 years ago

@chika0801 尝试了一下文档中的配置方法,cn 域名依然无法被 localhost 解析

chika0801 commented 2 years ago

@chika0801 尝试了一下文档中的配置方法,cn 域名依然无法被 localhost 解析

建议你日志开debug,访问一个域名,看日志了解流程

Aniark commented 2 years ago

@chika0801 尝试了一下文档中的配置方法,cn 域名依然无法被 localhost 解析

建议你日志开debug,访问一个域名,看日志了解流程

看了一下日志,dns 有被如期劫持,cn 域名也有被分流到 localhost ,但是解析步骤中出现了 failed 以下为日志

2022/10/23 04:10:30 [Info] app/dns: failed to lookup ip for domain fanyi.baidu.com at server localhost > lookup fanyi.baidu.com on [::1]:53: dial udp [::1]:53: connect: cannot assign requested address

chika0801 commented 2 years ago

@chika0801 尝试了一下文档中的配置方法,cn 域名依然无法被 localhost 解析

建议你日志开debug,访问一个域名,看日志了解流程

看了一下日志,dns 有被如期劫持,cn 域名也有被分流到 localhost ,但是解析步骤中出现了 failed 以下为日志

2022/10/23 04:10:30 [Info] app/dns: failed to lookup ip for domain fanyi.baidu.com at server localhost > lookup fanyi.baidu.com on [::1]:53: dial udp [::1]:53: connect: cannot assign requested address

你得发完整配置,日志前后部分,别人才能帮到你

Aniark commented 2 years ago

@chika0801

base.json { "log": { "access": "/data/adb/xray/run/access.log", "loglevel": "debug", "dnsLog": true }, "inbounds": [ { "tag": "proxy-in", "port": 65535, "protocol": "dokodemo-door", "settings": { "network": "tcp,udp", "followRedirect": true }, "streamSettings": { "sockopt": { "tproxy": "tproxy" } }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "fakedns" ] } } ], "outbounds": [ { "tag": "direct", "protocol": "freedom" }, { "tag": "block", "protocol": "blackhole", "settings": { "response": { "type": "http" } }, "streamSettings": null, "mux": null }, { "tag": "dns-out", "protocol": "dns" } ] }

dns.json { "dns": { "servers": [ { "address": "localhost", "domains": [ "geosite:geolocation-cn" ] }, { "address": "fakedns", "domains": [ "geosite:geolocation-!cn" ] }, "localhost" ], "tag": "dns", "queryStrategy": "UseIP" } }

proxy.json { "outbounds": [ { "tag": "proxy", "protocol": "VLESS", "settings": { "vnext": [ { "address": "114.514.1919.810", "port": 443, "users": [ { "id": "?", "encryption": "none"

"flow": "xtls-rprx-splice"

                        }
                    ]
                }
            ]
        },
        "streamSettings": {
            "network": "tcp",
            "security": "tls",
            "tlsSettings": {
                "allowInsecure": false,
                "serverName": "feelsgood.man"
            }
        }
    }
]

}

routing.json { "routing": { "domainStrategy": "IPIfNonMatch", "rules": [ { "type": "field", "port": 53, "inboundTag": [ "proxy-in" ], "outboundTag": "dns-out" }, { "domains": [ "geosite:geolocation-!cn" ], "outboundTag": "proxy", "type": "field" }, { "ip": [ "geoip:cn", "geoip:private" ], "outboundTag": "direct", "type": "field" }, { "domains": [ "geosite:cn", "geosite:private" ], "outboundTag": "direct", "type": "field" }, { "network": "tcp,udp", "outboundTag": "proxy", "type": "field" } ] } }

access.log 2022/10/23 07:13:56 10.166.61.170:63991 accepted udp:221.7.136.69:53 [proxy-in -> dns-out] 2022/10/23 07:14:01 10.166.61.170:47934 accepted udp:221.7.128.69:53 [proxy-in -> dns-out] 2022/10/23 07:14:03 10.166.61.170:64632 accepted udp:221.7.136.69:53 [proxy-in -> dns-out] 2022/10/23 07:14:03 10.166.61.170:63880 accepted udp:221.7.136.69:53 [proxy-in -> dns-out] 2022/10/23 07:14:03 10.166.61.170:44706 accepted tcp:198.19.4.20:443 [proxy-in -> proxy] 2022/10/23 07:14:03 10.166.61.170:44710 accepted tcp:198.19.4.20:443 [proxy-in -> proxy] 2022/10/23 07:14:06 10.166.61.170:39715 accepted udp:221.7.136.69:53 [proxy-in -> dns-out] 2022/10/23 07:14:06 10.166.61.170:49221 accepted udp:221.7.136.69:53 [proxy-in -> dns-out] 2022/10/23 07:14:06 10.166.61.170:42132 accepted tcp:198.19.16.43:443 [proxy-in -> proxy] 2022/10/23 07:14:06 10.166.61.170:46414 accepted udp:221.7.136.69:53 [proxy-in -> dns-out] 2022/10/23 07:14:06 10.166.61.170:48944 accepted udp:221.7.136.69:53 [proxy-in -> dns-out] 2022/10/23 07:14:07 10.166.61.170:48653 accepted udp:221.7.136.69:53 [proxy-in -> dns-out] 2022/10/23 07:14:07 10.166.61.170:61995 accepted udp:221.7.136.69:53 [proxy-in -> dns-out] 2022/10/23 07:14:07 10.166.61.170:39808 accepted tcp:198.19.18.12:443 [proxy-in -> proxy] 2022/10/23 07:14:07 10.166.61.170:38394 accepted tcp:198.19.18.111:443 [proxy-in -> proxy] 2022/10/23 07:14:07 10.166.61.170:38398 accepted tcp:198.19.18.111:443 [proxy-in -> proxy] 2022/10/23 07:14:07 10.166.61.170:39822 accepted tcp:198.19.18.12:443 [proxy-in -> proxy] 2022/10/23 07:14:07 10.166.61.170:38406 accepted tcp:198.19.18.111:443 [proxy-in -> proxy]

error.log Xray 1.6.0 (Xray, Penetrates Everything.) Custom (go1.19.1 android/arm64) A unified platform for anti-censorship. 2022/10/23 07:13:50 Using confdir from env: /data/adb/xray/confs 2022/10/23 07:13:50 [Info] infra/conf/serial: Reading config: /data/adb/xray/confs/base.json xctl> [ /data/adb/xray/confs/proxy.json ] prepended outbound with tag: proxy 2022/10/23 07:13:50 [Info] infra/conf/serial: Reading config: /data/adb/xray/confs/dns.json 2022/10/23 07:13:50 [Info] infra/conf/serial: Reading config: /data/adb/xray/confs/proxy.json 2022/10/23 07:13:50 [Info] infra/conf/serial: Reading config: /data/adb/xray/confs/routing.json 2022/10/23 07:13:50 [Debug] app/log: Logger started 2022/10/23 07:13:50 [Info] app/dns: DNS: created localhost client 2022/10/23 07:13:50 [Info] app/dns: DNS: created localhost client 2022/10/23 07:13:50 [Debug] app/router: MphDomainMatcher is enabled for 13493 domain rule(s) 2022/10/23 07:13:50 [Debug] app/router: MphDomainMatcher is enabled for 3099 domain rule(s) 2022/10/23 07:13:50 [Debug] app/proxyman/inbound: creating stream worker on 0.0.0.0:65535 2022/10/23 07:13:50 [Info] transport/internet/tcp: listening TCP on 0.0.0.0:65535 2022/10/23 07:13:50 [Info] transport/internet/udp: listening UDP on 0.0.0.0:65535 2022/10/23 07:13:50 [Warning] core: Xray 1.6.0 started 2022/10/23 07:13:56 [Debug] transport/internet/udp: UDP original destination: udp:221.7.136.69:53 2022/10/23 07:13:56 [Debug] [2921831885] proxy/dokodemo: processing connection from: 10.166.61.170:63991 2022/10/23 07:13:56 [Info] [2921831885] proxy/dokodemo: received request for 10.166.61.170:63991 2022/10/23 07:13:56 [Info] [2921831885] app/dispatcher: taking detour [dns-out] for [udp:221.7.136.69:53] 2022/10/23 07:13:56 [Info] [2921831885] proxy/dns: handling DNS traffic to udp:221.7.136.69:53 2022/10/23 07:13:56 [Debug] app/dns: domain fanyi.baidu.com matches following rules: [geosite:geolocation-cn(DNS idx:0)] 2022/10/23 07:13:56 [Debug] app/dns: domain fanyi.baidu.com will use DNS in order: [localhost FakeDNS localhost] 2022/10/23 07:13:56 [Info] app/dns: failed to lookup ip for domain fanyi.baidu.com at server localhost > lookup fanyi.baidu.com on [::1]:53: dial udp [::1]:53: connect: cannot assign requested address 2022/10/23 07:13:56 [Info] proxy/dns: ip query > lookup fanyi.baidu.com on [::1]:53: dial udp [::1]:53: connect: cannot assign requested address 2022/10/23 07:14:01 [Debug] transport/internet/udp: UDP original destination: udp:221.7.128.69:53 2022/10/23 07:14:01 [Debug] [3609177453] proxy/dokodemo: processing connection from: 10.166.61.170:47934 2022/10/23 07:14:01 [Info] [3609177453] proxy/dokodemo: received request for 10.166.61.170:47934 2022/10/23 07:14:01 [Info] [3609177453] app/dispatcher: taking detour [dns-out] for [udp:221.7.128.69:53] 2022/10/23 07:14:01 [Info] [3609177453] proxy/dns: handling DNS traffic to udp:221.7.128.69:53 2022/10/23 07:14:01 [Debug] app/dns: domain fanyi.baidu.com matches following rules: [geosite:geolocation-cn(DNS idx:0)] 2022/10/23 07:14:01 [Debug] app/dns: domain fanyi.baidu.com will use DNS in order: [localhost FakeDNS localhost] 2022/10/23 07:14:03 [Debug] transport/internet/udp: UDP original destination: udp:221.7.136.69:53 2022/10/23 07:14:03 [Debug] [3487210963] proxy/dokodemo: processing connection from: 10.166.61.170:64632 2022/10/23 07:14:03 [Info] [3487210963] proxy/dokodemo: received request for 10.166.61.170:64632 2022/10/23 07:14:03 [Info] [3487210963] app/dispatcher: taking detour [dns-out] for [udp:221.7.136.69:53] 2022/10/23 07:14:03 [Info] [3487210963] proxy/dns: handling DNS traffic to udp:221.7.136.69:53 2022/10/23 07:14:03 [Debug] app/dns: domain github.com matches following rules: [geosite:geolocation-!cn(DNS idx:1)] 2022/10/23 07:14:03 [Debug] app/dns: domain github.com will use DNS in order: [FakeDNS localhost localhost] 2022/10/23 07:14:03 [Info] app/dns: FakeDNS got answer: github.com -> [[fc00::184:3b1:402]] 2022/10/23 07:14:03 [Debug] transport/internet/udp: UDP original destination: udp:221.7.136.69:53 2022/10/23 07:14:03 [Debug] [4116168101] proxy/dokodemo: processing connection from: 10.166.61.170:63880 2022/10/23 07:14:03 [Info] [4116168101] proxy/dokodemo: received request for 10.166.61.170:63880 2022/10/23 07:14:03 [Info] [4116168101] app/dispatcher: taking detour [dns-out] for [udp:221.7.136.69:53] 2022/10/23 07:14:03 [Info] [4116168101] proxy/dns: handling DNS traffic to udp:221.7.136.69:53 2022/10/23 07:14:03 [Debug] app/dns: domain github.com matches following rules: [geosite:geolocation-!cn(DNS idx:1)] 2022/10/23 07:14:03 [Debug] app/dns: domain github.com will use DNS in order: [FakeDNS localhost localhost] 2022/10/23 07:14:03 [Info] app/dns: FakeDNS got answer: github.com -> [198.19.4.20] 2022/10/23 07:14:03 [Debug] [35508054] proxy/dokodemo: processing connection from: 10.166.61.170:44706 2022/10/23 07:14:03 [Info] [35508054] proxy/dokodemo: received request for 10.166.61.170:44706 2022/10/23 07:14:03 [Info] [35508054] app/dispatcher: fake dns got domain: github.com for ip: 198.19.4.20 2022/10/23 07:14:03 [Info] [35508054] app/dispatcher: sniffed domain: github.com 2022/10/23 07:14:03 [Info] [35508054] app/dispatcher: taking detour [proxy] for [tcp:github.com:443] 2022/10/23 07:14:03 [Info] [35508054] transport/internet/tcp: dialing TCP to tcp:114.514.1919.810:443 2022/10/23 07:14:03 [Debug] transport/internet: dialing to tcp:114.514.1919.810:443 2022/10/23 07:14:03 [Debug] [4153560601] proxy/dokodemo: processing connection from: 10.166.61.170:44710 2022/10/23 07:14:03 [Info] [4153560601] proxy/dokodemo: received request for 10.166.61.170:44710 2022/10/23 07:14:03 [Info] [4153560601] app/dispatcher: fake dns got domain: github.com for ip: 198.19.4.20 2022/10/23 07:14:03 [Info] [4153560601] app/dispatcher: sniffed domain: github.com 2022/10/23 07:14:03 [Info] [4153560601] app/dispatcher: taking detour [proxy] for [tcp:github.com:443] 2022/10/23 07:14:03 [Info] [4153560601] transport/internet/tcp: dialing TCP to tcp:114.514.1919.810:443 2022/10/23 07:14:03 [Debug] transport/internet: dialing to tcp:114.514.1919.810:443 2022/10/23 07:14:03 [Info] [35508054] proxy/vless/outbound: tunneling request to tcp:github.com:443 via 114.514.1919.810:443 2022/10/23 07:14:04 [Info] [4153560601] proxy/vless/outbound: tunneling request to tcp:github.com:443 via 114.514.1919.810:443 2022/10/23 07:14:06 [Debug] transport/internet/udp: UDP original destination: udp:221.7.136.69:53 2022/10/23 07:14:06 [Debug] [4188515691] proxy/dokodemo: processing connection from: 10.166.61.170:39715 2022/10/23 07:14:06 [Info] [4188515691] proxy/dokodemo: received request for 10.166.61.170:39715 2022/10/23 07:14:06 [Info] [4188515691] app/dispatcher: taking detour [dns-out] for [udp:221.7.136.69:53] 2022/10/23 07:14:06 [Info] [4188515691] proxy/dns: handling DNS traffic to udp:221.7.136.69:53 2022/10/23 07:14:06 [Debug] app/dns: domain alive.github.com matches following rules: [geosite:geolocation-!cn(DNS idx:1)] 2022/10/23 07:14:06 [Debug] app/dns: domain alive.github.com will use DNS in order: [FakeDNS localhost localhost] 2022/10/23 07:14:06 [Info] app/dns: FakeDNS got answer: alive.github.com -> [[fc00::184:3b1:1027]] 2022/10/23 07:14:06 [Debug] transport/internet/udp: UDP original destination: udp:221.7.136.69:53 2022/10/23 07:14:06 [Debug] [455307800] proxy/dokodemo: processing connection from: 10.166.61.170:49221 2022/10/23 07:14:06 [Info] [455307800] proxy/dokodemo: received request for 10.166.61.170:49221 2022/10/23 07:14:06 [Info] [455307800] app/dispatcher: taking detour [dns-out] for [udp:221.7.136.69:53] 2022/10/23 07:14:06 [Info] [455307800] proxy/dns: handling DNS traffic to udp:221.7.136.69:53 2022/10/23 07:14:06 [Debug] app/dns: domain alive.github.com matches following rules: [geosite:geolocation-!cn(DNS idx:1)] 2022/10/23 07:14:06 [Debug] app/dns: domain alive.github.com will use DNS in order: [FakeDNS localhost localhost] 2022/10/23 07:14:06 [Info] app/dns: FakeDNS got answer: alive.github.com -> [198.19.16.43] 2022/10/23 07:14:06 [Debug] transport/internet/udp: UDP original destination: udp:221.7.136.69:53 2022/10/23 07:14:06 [Debug] app/dns: domain fanyi.baidu.com matches following rules: [geosite:geolocation-cn(DNS idx:0)] 2022/10/23 07:14:06 [Debug] app/dns: domain fanyi.baidu.com will use DNS in order: [localhost FakeDNS localhost] 2022/10/23 07:14:06 [Debug] [1197954405] proxy/dokodemo: processing connection from: 10.166.61.170:42132 2022/10/23 07:14:06 [Info] [1197954405] proxy/dokodemo: received request for 10.166.61.170:42132 2022/10/23 07:14:06 [Info] [1197954405] app/dispatcher: fake dns got domain: alive.github.com for ip: 198.19.16.43 2022/10/23 07:14:06 [Info] [1197954405] app/dispatcher: sniffed domain: alive.github.com 2022/10/23 07:14:06 [Info] [1197954405] app/dispatcher: taking detour [proxy] for [tcp:alive.github.com:443] 2022/10/23 07:14:06 [Info] [1197954405] transport/internet/tcp: dialing TCP to tcp:114.514.1919.810:443 2022/10/23 07:14:06 [Debug] transport/internet: dialing to tcp:114.514.1919.810:443 2022/10/23 07:14:06 [Debug] transport/internet/udp: UDP original destination: udp:221.7.136.69:53 2022/10/23 07:14:06 [Debug] [2527087415] proxy/dokodemo: processing connection from: 10.166.61.170:46414 2022/10/23 07:14:06 [Info] [2527087415] proxy/dokodemo: received request for 10.166.61.170:46414 2022/10/23 07:14:06 [Info] [2527087415] app/dispatcher: taking detour [dns-out] for [udp:221.7.136.69:53] 2022/10/23 07:14:06 [Info] [2527087415] proxy/dns: handling DNS traffic to udp:221.7.136.69:53 2022/10/23 07:14:06 [Debug] app/dns: domain collector.github.com matches following rules: [geosite:geolocation-!cn(DNS idx:1)] 2022/10/23 07:14:06 [Debug] app/dns: domain collector.github.com will use DNS in order: [FakeDNS localhost localhost] 2022/10/23 07:14:06 [Info] app/dns: FakeDNS got answer: collector.github.com -> [[fc00::184:3b1:1208]] 2022/10/23 07:14:06 [Debug] transport/internet/udp: UDP original destination: udp:221.7.136.69:53 2022/10/23 07:14:06 [Debug] [3098570342] proxy/dokodemo: processing connection from: 10.166.61.170:48944 2022/10/23 07:14:06 [Info] [3098570342] proxy/dokodemo: received request for 10.166.61.170:48944 2022/10/23 07:14:06 [Info] [3098570342] app/dispatcher: taking detour [dns-out] for [udp:221.7.136.69:53] 2022/10/23 07:14:06 [Info] [3098570342] proxy/dns: handling DNS traffic to udp:221.7.136.69:53 2022/10/23 07:14:06 [Debug] app/dns: domain collector.github.com matches following rules: [geosite:geolocation-!cn(DNS idx:1)] 2022/10/23 07:14:06 [Debug] app/dns: domain collector.github.com will use DNS in order: [FakeDNS localhost localhost] 2022/10/23 07:14:06 [Info] app/dns: FakeDNS got answer: collector.github.com -> [198.19.18.12] 2022/10/23 07:14:06 [Info] [1197954405] proxy/vless/outbound: tunneling request to tcp:alive.github.com:443 via 114.514.1919.810:443 2022/10/23 07:14:07 [Debug] transport/internet/udp: UDP original destination: udp:221.7.136.69:53 2022/10/23 07:14:07 [Debug] [401251622] proxy/dokodemo: processing connection from: 10.166.61.170:48653 2022/10/23 07:14:07 [Info] [401251622] proxy/dokodemo: received request for 10.166.61.170:48653 2022/10/23 07:14:07 [Info] [401251622] app/dispatcher: taking detour [dns-out] for [udp:221.7.136.69:53] 2022/10/23 07:14:07 [Info] [401251622] proxy/dns: handling DNS traffic to udp:221.7.136.69:53 2022/10/23 07:14:07 [Debug] app/dns: domain api.github.com matches following rules: [geosite:geolocation-!cn(DNS idx:1)] 2022/10/23 07:14:07 [Debug] app/dns: domain api.github.com will use DNS in order: [FakeDNS localhost localhost] 2022/10/23 07:14:07 [Info] app/dns: FakeDNS got answer: api.github.com -> [[fc00::184:3b1:126c]] 2022/10/23 07:14:07 [Debug] transport/internet/udp: UDP original destination: udp:221.7.136.69:53 2022/10/23 07:14:07 [Debug] [2426667179] proxy/dokodemo: processing connection from: 10.166.61.170:61995 2022/10/23 07:14:07 [Info] [2426667179] proxy/dokodemo: received request for 10.166.61.170:61995 2022/10/23 07:14:07 [Info] [2426667179] app/dispatcher: taking detour [dns-out] for [udp:221.7.136.69:53] 2022/10/23 07:14:07 [Info] [2426667179] proxy/dns: handling DNS traffic to udp:221.7.136.69:53 2022/10/23 07:14:07 [Debug] app/dns: domain api.github.com matches following rules: [geosite:geolocation-!cn(DNS idx:1)] 2022/10/23 07:14:07 [Debug] app/dns: domain api.github.com will use DNS in order: [FakeDNS localhost localhost] 2022/10/23 07:14:07 [Info] app/dns: FakeDNS got answer: api.github.com -> [198.19.18.111] 2022/10/23 07:14:07 [Debug] [2323448818] proxy/dokodemo: processing connection from: 10.166.61.170:39808 2022/10/23 07:14:07 [Info] [2323448818] proxy/dokodemo: received request for 10.166.61.170:39808 2022/10/23 07:14:07 [Info] [2323448818] app/dispatcher: fake dns got domain: collector.github.com for ip: 198.19.18.12 2022/10/23 07:14:07 [Info] [2323448818] app/dispatcher: sniffed domain: collector.github.com 2022/10/23 07:14:07 [Info] [2323448818] app/dispatcher: taking detour [proxy] for [tcp:collector.github.com:443] 2022/10/23 07:14:07 [Info] [2323448818] transport/internet/tcp: dialing TCP to tcp:114.514.1919.810:443 2022/10/23 07:14:07 [Debug] transport/internet: dialing to tcp:114.514.1919.810:443 2022/10/23 07:14:07 [Debug] [2757410456] proxy/dokodemo: processing connection from: 10.166.61.170:38394 2022/10/23 07:14:07 [Info] [2757410456] proxy/dokodemo: received request for 10.166.61.170:38394 2022/10/23 07:14:07 [Info] [2757410456] app/dispatcher: fake dns got domain: api.github.com for ip: 198.19.18.111 2022/10/23 07:14:07 [Info] [2757410456] app/dispatcher: sniffed domain: api.github.com 2022/10/23 07:14:07 [Info] [2757410456] app/dispatcher: taking detour [proxy] for [tcp:api.github.com:443] 2022/10/23 07:14:07 [Info] [2757410456] transport/internet/tcp: dialing TCP to tcp:114.514.1919.810:443 2022/10/23 07:14:07 [Debug] transport/internet: dialing to tcp:114.514.1919.810:443 2022/10/23 07:14:07 [Debug] [297565842] proxy/dokodemo: processing connection from: 10.166.61.170:38398 2022/10/23 07:14:07 [Info] [297565842] proxy/dokodemo: received request for 10.166.61.170:38398 2022/10/23 07:14:07 [Info] [297565842] app/dispatcher: fake dns got domain: api.github.com for ip: 198.19.18.111 2022/10/23 07:14:07 [Info] [297565842] app/dispatcher: sniffed domain: api.github.com 2022/10/23 07:14:07 [Info] [297565842] app/dispatcher: taking detour [proxy] for [tcp:api.github.com:443] 2022/10/23 07:14:07 [Info] [297565842] transport/internet/tcp: dialing TCP to tcp:114.514.1919.810:443 2022/10/23 07:14:07 [Debug] transport/internet: dialing to tcp:114.514.1919.810:443 2022/10/23 07:14:07 [Info] [2323448818] proxy/vless/outbound: tunneling request to tcp:collector.github.com:443 via 114.514.1919.810:443 2022/10/23 07:14:07 [Debug] [106696786] proxy/dokodemo: processing connection from: 10.166.61.170:39822 2022/10/23 07:14:07 [Info] [106696786] proxy/dokodemo: received request for 10.166.61.170:39822 2022/10/23 07:14:07 [Info] [106696786] app/dispatcher: fake dns got domain: collector.github.com for ip: 198.19.18.12 2022/10/23 07:14:07 [Info] [106696786] app/dispatcher: sniffed domain: collector.github.com 2022/10/23 07:14:07 [Info] [106696786] app/dispatcher: taking detour [proxy] for [tcp:collector.github.com:443] 2022/10/23 07:14:07 [Info] [106696786] transport/internet/tcp: dialing TCP to tcp:114.514.1919.810:443 2022/10/23 07:14:07 [Debug] transport/internet: dialing to tcp:114.514.1919.810:443 2022/10/23 07:14:07 [Info] [2757410456] proxy/vless/outbound: tunneling request to tcp:api.github.com:443 via 114.514.1919.810:443 2022/10/23 07:14:07 [Info] [297565842] proxy/vless/outbound: tunneling request to tcp:api.github.com:443 via 114.514.1919.810:443 2022/10/23 07:14:07 [Debug] [4067897998] proxy/dokodemo: processing connection from: 10.166.61.170:38406 2022/10/23 07:14:07 [Info] [4067897998] proxy/dokodemo: received request for 10.166.61.170:38406 2022/10/23 07:14:07 [Info] [4067897998] app/dispatcher: fake dns got domain: api.github.com for ip: 198.19.18.111 2022/10/23 07:14:07 [Info] [4067897998] app/dispatcher: sniffed domain: api.github.com 2022/10/23 07:14:07 [Info] [4067897998] app/dispatcher: taking detour [proxy] for [tcp:api.github.com:443] 2022/10/23 07:14:07 [Info] [4067897998] transport/internet/tcp: dialing TCP to tcp:114.514.1919.810:443 2022/10/23 07:14:07 [Debug] transport/internet: dialing to tcp:114.514.1919.810:443 2022/10/23 07:14:07 [Info] [106696786] proxy/vless/outbound: tunneling request to tcp:collector.github.com:443 via 114.514.1919.810:443 2022/10/23 07:14:07 [Info] [4067897998] proxy/vless/outbound: tunneling request to tcp:api.github.com:443 via 114.514.1919.810:443 2022/10/23 07:14:11 [Debug] app/log: Logger closing

chika0801 commented 2 years ago

https://www.v2fly.org/config/fakedns.html#%E4%B8%8E-dns-%E5%88%86%E6%B5%81%E5%85%B1%E5%AD%98 这段话你理解错了,我给你改了下 dns模块

{
    "dns":{
        "servers":[
            {
                "address":"fakedns",
                "domains":[
                    "geosite:geolocation-!cn"
                ]
            },
            {
                "address":"223.5.5.5",
                "domains":[
                    "geosite:geolocation-!cn"
                ]
            }
            "223.5.5.5"
        ],
        "tag":"dns",
        "queryStrategy":"UseIPv4"
    }
}

看error日志里baidu.com请求失败的,你把localhost改为223.5.5.5测试下

chika0801 commented 2 years ago

建议你不太懂xray dns处理逻辑的话,就别用。

安卓手机,用v2rayng,用分应用代理,一样的效果

我是在v2rayng里用Fakedns功能,我的示例如下

点击查看详细步骤 ```console { "log": { "access": "", "error": "", "loglevel": "warning" }, "dns": { "servers": [ "fakedns", "1.1.1.1" ], "queryStrategy": "UseIPv4" }, "routing": { "domainStrategy": "IPIfNonMatch", "rules": [ { "type": "field", "inboundTag": [ "dns-in" ], "outboundTag": "dns-out" }, { "type": "field", "ip": [ "1.1.1.1" ], "outboundTag": "proxy" }, { "type": "field", "domain": [ "geosite:category-ads-all" ], "outboundTag": "block" }, { "type": "field", "domain": [ "geosite:geolocation-!cn" ], "outboundTag": "proxy" }, { "type": "field", "domain": [ "geosite:tld-cn", "geosite:cn" ], "outboundTag": "direct" }, { "type": "field", "ip": [ "geoip:cn", "geoip:private" ], "outboundTag": "direct" } ] }, "inbounds": [ { "listen": "127.0.0.1", "port": 10808, "protocol": "socks", "settings": { "udp": true }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "fakedns" ] } }, { "listen": "127.0.0.1", "port": 10809, "protocol": "http", "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "fakedns" ] } }, { "listen": "127.0.0.1", "port": 10853, "protocol": "dokodemo-door", "settings": { "address": "1.1.1.1", "port": 53, "network": "tcp,udp" }, "tag": "dns-in" } ], "outbounds": [ { "protocol": "vless", "settings": { "vnext": [ { "address": "", "port": 443, "users": [ { "id": "", "encryption": "none", "flow": "xtls-rprx-splice" } ] } ] }, "streamSettings": { "network": "tcp", "security": "xtls", "xtlsSettings": { "serverName": "", "allowInsecure": false } }, "tag": "proxy" }, { "protocol": "freedom", "settings": { "domainStrategy": "AsIs" }, "tag": "direct" }, { "protocol": "blackhole", "settings": { "response": { "type": "http" } }, "tag": "block" }, { "protocol": "dns", "proxySettings": { "tag": "proxy" }, "tag": "dns-out" } ] } ```
Aniark commented 2 years ago

@chika0801 谢谢大佬的解答,不过也许是我表述得不够清楚,让您误会了我想解决的问题

我想解决的问题无关 fakedns

我想解决的问题有关 localhost ,见此段落 ,localhost 预期应该正常解析 cn 域名,但是却没有

在下的使用网络是手机数据,localhost 预期应该是运营商提供的 dns ;不过刚刚我尝试 v2rayng ,同样的 dns 分流配置在 v2rayng 如期运行,在下先去 Xray4Magisk 那边问问

zyf0330 commented 1 year ago

这里应该是这样的,在 Android 上,localhost 并不能访问到 local dns。我检查过,Android 的系统 DNS 服务并不会启动 localhost:53 dns 服务器,不确定 xray 是否适配了 Android 的系统 DNS