chika0801 / sing-box-examples

sing-box 配置示例
https://github.com/SagerNet/sing-box
1.61k stars 270 forks source link

fakeip疑问? #83

Closed shallbytwo closed 6 months ago

shallbytwo commented 6 months ago
            {
                "rule_set": "geosite-geolocation-!cn",
                "query_type": [
                    "A",
                    "AAAA"
                ],
                "server": "dns_fakeip"
            },
            {
                "rule_set": "geosite-geolocation-!cn",
                "server": "dns_proxy"
            },

以上代码来自https://github.com/chika0801/sing-box-examples/blob/main/Tun/config_client_android_remote_dns_with_fakeip.json。 请问geosite-geolocation-!cn都走了dns_fakeip了,为什么下面还有个geosite-geolocation-!cn走dns_proxy的规则呢?按理说都已经走dns_fakeip了,这个rule不会被匹配到了是吗?也就是下面的{ "rule_set": "geosite-geolocation-!cn", "server": "dns_proxy" },可以删了吧?

chika0801 commented 6 months ago

fakeip只对a aaaa的查询有效,所以有句query type

下面1个规则,就是把geo!cn的非 a aaaa 查询送到远程dns的意思。

shallbytwo commented 6 months ago

但是我看不是有个兜底规则"final": "dns_proxy",。不写那个也会走proxydns吧

chika0801 commented 6 months ago
        {
            "rule_set": "geosite-cn",
            "server": "dns_direct"
        },
        {
            "rule_set": "geosite-category-companies@cn",
            "server": "dns_direct"
        }

原理是后面有这2个规则,逻辑是万一在geosite!cn中的域名发起非a aaaa请求,未命中fakeip规则,此时这域名又在geosite cn中,就命中了dns direct了。 按这逻辑,你其实每写一个域名规则集要走fakeip时,后面都应该跟一个非a aaaa走你想要的远程/本地dns查询。

你不考虑这么细倒也无所谓,就像你说的反正有final如proxy.

这些细节是写(用)久了,积累下来的个人习惯。