SagerNet / sing-box

The universal proxy platform
https://sing-box.sagernet.org/
Other
15.5k stars 1.9k forks source link

开启store_rdrc似乎会污染DNS查询时域名的geo判断 #1798

Closed 3zsvvev7 closed 4 weeks ago

3zsvvev7 commented 1 month ago

操作系统

macOS

系统版本

14.5 (23F79)

安装类型

sing-box 原始命令行程序

如果您使用图形客户端程序,请提供该程序版本。

No response

版本

sing-box version 1.9.0

Environment: go1.22.3 darwin/amd64
Tags: with_gvisor,with_quic,with_dhcp,with_wireguard,with_ech,with_utls,with_reality_server,with_acme,with_clash_api
Revision: 5ff7006326e8a876d33d92b26ebd2671cdd48b9f
CGO: disabled

描述

开启store_rdrc似乎会污染DNS查询时域名的geo判断

重现方式

测试域名www.gzmtr.com只有两个固定A的记录,将这两个A记录添加DNS到dns.rules, 开启 store_rdrc,然后 dig 该域名,刚开始返回了期望的A记录,但是大约十分左右后 dig 就会返回fake ip,这是100%复现的,关闭store_rdrc就无法再复现了。

{
    "dns":
    {
        "final": "alidns",
        "strategy": "prefer_ipv4",
        "independent_cache": true,
        "fakeip": {
            "enabled": true,
            "inet4_range": "198.18.0.0/15",
            "inet6_range": "fc00::/18"
        },
        "rules":
        [
            {
                "ip_cidr": [
                    "218.107.39.81/32",
                    "120.238.32.98/32"
                ],
                "server": "alidns"
            },
            {
                "query_type": ["A","AAAA"],
                "server": "remote"
            }
        ],
        "servers":
        [
            {
                "tag": "alidns",
                "address": "https://223.5.5.5/dns-query",
                "strategy": "ipv4_only",
                "detour": "direct"
            },
            {
                "tag": "remote",
                "strategy": "ipv4_only",
                "address": "fakeip"
            }
        ]
    },
    "experimental":
    {
        "cache_file":
        {
            "store_rdrc": true,
            "store_fakeip": true,
            "enabled": true
        }
    },
    "inbounds":
    [
        {
            "auto_route": true,
            "inet4_address": "172.19.0.1/30",
            "sniff": true,
            "stack": "mixed",
            "strict_route": true,
            "type": "tun"
        }
    ],
    "log":
    {
        "disabled": false,
        "level": "warn",
        "output": "box.log",
        "timestamp": true
    },
    "outbounds":
    [
        {
            "outbounds":[],
            "tag": "proxy",
            "type": "selector"
        },
        {
            "tag": "direct",
            "type": "direct",
            "domain_strategy": "prefer_ipv4"
        },
        {
            "tag": "block",
            "type": "block"
        },
        {
            "tag": "dns-out",
            "type": "dns"
        }
    ],
    "route":
    {
        "auto_detect_interface": true,
        "final": "proxy",
        "rules":
        [
            {
                "outbound": "dns-out",
                "port": 53
            }
        ]
    }
}

日志

No response

支持我们

完整性要求

dyhkwong commented 4 weeks ago

该域名没有 AAAA 记录,查询 AAAA 时不会匹配 ipv4 的 ip_cidr。