2dust / v2rayN

A GUI client for Windows, support Xray core and v2fly core and others
https://1.2345345.xyz
GNU General Public License v3.0
67.21k stars 11.21k forks source link

[Bug]: tun模式 DNS设置,自定义dns设置不生效 #3942

Closed WoChen5770 closed 1 year ago

WoChen5770 commented 1 year ago

预期情况

生效

实际情况

image image 启动后配置文件会自动加上下面这个local_local:223.5.5.5,导致自己设置的local dns不生效 { "tag": "local_local", "address": "223.5.5.5", "detour": "direct" }

复现方法

自定义tun dns

日志信息

额外信息

No response

我确认已更新至最新版本

我确认已查询历史issues

chika0801 commented 1 year ago

local_local 是有意为之,用意是你的节点地址是域名是,这个DNS来解析这个域名为IP才有发动访问。

至于你想研究为什么你的配置有什么问题,你需要把v2rayN生成的sing-box配置发上来,并说明(以你访问什么网站怎么怎么样的问题)才能帮你看看。

你也可以把日志调为Debug是,访问网站,看日志,来追踪处理流程。

chika0801 commented 1 year ago

如果你想尝试全手动开TUN,推荐你看这个 https://github.com/chika0801/sing-box-examples/tree/main/Tun

WoChen5770 commented 1 year ago

local_local 是有意为之,用意是你的节点地址是域名是,这个DNS来解析这个域名为IP才有发动访问。

至于你想研究为什么你的配置有什么问题,你需要把v2rayN生成的sing-box配置发上来,并说明(以你访问什么网站怎么怎么样的问题)才能帮你看看。

你也可以把日志调为Debug是,访问网站,看日志,来追踪处理流程。

我导入默认的dns配置后,就只把 默认的223.5.5.5 改成了我自己的dns服务器。 启用tun模式,访问任意网站后,都没有在dns服务里看到有请求dns日志。不用tun就正常了,这个问题应该很好重现。 v2rayn的debug日志上班有时间再看看

chika0801 commented 1 year ago

需要你提供v2rayN生成的Sing-box配置文件,才能帮你分析了。

WoChen5770 commented 1 year ago

{ "log": { "level": "warn", "timestamp": true }, "dns": { "servers": [ { "tag": "remote", "address": "tcp://8.8.8.8", "detour": "proxy" }, { "tag": "local", "address": "10.20.30.10", "detour": "direct" }, { "tag": "block", "address": "rcode://success" }, { "tag": "local_local", "address": "223.5.5.5", "detour": "direct" } ], "rules": [ { "server": "local", "disable_cache": true, "geosite": [ "cn" ] }, { "server": "block", "disable_cache": true, "geosite": [ "category-ads-all" ] }, { "outbound": "any", "server": "local_local" } ], "strategy": "ipv4_only" }, "inbounds": [ { "type": "tun", "tag": "tun-in", "interface_name": "singbox_tun", "inet4_address": "172.19.0.1/30", "inet6_address": "fdfe:dcba:9876::1/126", "mtu": 9000, "auto_route": true, "strict_route": false, "stack": "gvisor", "sniff": true } ], "outbounds": [ { "type": "vless", "tag": "proxy", "server": "***", "server_port": 443, "uuid": "**", "flow": "xtls-rprx-vision", "packet_encoding": "xudp", "tls": { "enabled": true, "server_name": "itunes.apple.com", "insecure": false, "utls": { "enabled": true, "fingerprint": "chrome" }, "reality": { "enabled": true, "public_key": "***", "short_id": "" } } }, { "type": "direct", "tag": "direct" }, { "type": "block", "tag": "block" }, { "type": "dns", "tag": "dns_out" } ], "route": { "auto_detect_interface": true, "rules": [ { "outbound": "dns_out", "inbound": [ "dns_in" ] }, { "outbound": "dns_out", "protocol": [ "dns" ] }, { "outbound": "block", "network": "udp", "port": [ 135, 137, 138, 139, 5353 ] }, { "outbound": "block", "ip_cidr": [ "224.0.0.0/3", "ff00::/8" ] }, { "outbound": "block", "source_ip_cidr": [ "224.0.0.0/3", "ff00::/8" ] }, { "outbound": "dns_out", "port": [ 53 ], "process_name": [ "wv2ray.exe", "v2ray.exe", "SagerNet.exe", "v2ray.exe", "v2ray.exe", "xray.exe", "wxray.exe", "clash-windows-amd64-v3.exe", "clash-windows-amd64.exe", "clash-windows-386.exe", "clash.exe", "Clash.Meta-windows-amd64-compatible.exe", "Clash.Meta-windows-amd64.exe", "Clash.Meta-windows-386.exe", "Clash.Meta.exe", "clash.exe", "hysteria-windows-amd64.exe", "hysteria-windows-386.exe", "hysteria.exe", "naiveproxy.exe", "naive.exe", "tuic-client.exe", "tuic.exe" ] }, { "outbound": "direct", "process_name": [ "wv2ray.exe", "v2ray.exe", "SagerNet.exe", "v2ray.exe", "v2ray.exe", "xray.exe", "wxray.exe", "clash-windows-amd64-v3.exe", "clash-windows-amd64.exe", "clash-windows-386.exe", "clash.exe", "Clash.Meta-windows-amd64-compatible.exe", "Clash.Meta-windows-amd64.exe", "Clash.Meta-windows-386.exe", "Clash.Meta.exe", "clash.exe", "hysteria-windows-amd64.exe", "hysteria-windows-386.exe", "hysteria.exe", "naiveproxy.exe", "naive.exe", "tuic-client.exe", "tuic.exe", "sing-box-client.exe", "sing-box.exe" ] }, { "outbound": "direct", "inbound": [ "socks", "http", "socks2", "http2" ], "protocol": [ "bittorrent", "tls", "http" ], "geosite": [ "adobe", "adobe-activation", "apple", "apple-cn", "cn", "google-cn", "microsoft", "msn", "private" ], "domain_keyword": [ "adblockplus.org", "adservice.google.com", "baiyunju.cc", "bitwarden.com", "bitwarden.net", "googleads.g.doubleclick.net", "letsencrypt.org", "safesugar.net" ] }, { "outbound": "direct", "inbound": [ "socks", "http", "socks2", "http2" ], "protocol": [ "bittorrent", "tls", "http" ], "geoip": [ "cn", "private" ], "ip_cidr": [ "10.20.30.0/24", "132.122.0.0/16" ] }, { "outbound": "block", "geosite": [ "category-ads-all" ] }, { "outbound": "proxy", "geosite": [ "gfw", "greatfire", "tld-!cn" ], "domain_keyword": [ "fundgz.1234567.com.cn", "hostloc.com", "rime.im", "todesk.com", "v2ex.com" ] }, { "outbound": "proxy", "geoip": [ "cloudflare", "cloudfront", "facebook", "fastly", "google", "netflix", "telegram", "twitter" ] }, { "outbound": "direct", "port_range": [ "0:65535" ] } ] } }

WoChen5770 commented 1 year ago

需要你提供v2rayN生成的Sing-box配置文件,才能帮你分析了。

发来了,麻烦看看

chika0801 commented 1 year ago

帮你格式化了下

屏幕截图 2023-06-05 235205

你需要有些sing-box 配置和流程的知识。

只有满足这条件的,使用你的DNS查询。没命中的,走第1个DNS,图上是 "tag":"remote", 的。

我看得出来你不熟悉sing-boxTUN模式时 DNS处理流程 配置文件作用等。

点击查看
```jsonc { "log":{ "level":"warn", "timestamp":true }, "dns":{ "servers":[ { "tag":"remote", "address":"tcp://8.8.8.8", "detour":"proxy" }, { "tag":"local", "address":"10.20.30.10", "detour":"direct" }, { "tag":"block", "address":"rcode://success" }, { "tag":"local_local", "address":"223.5.5.5", "detour":"direct" } ], "rules":[ { "server":"local", "disable_cache":true, "geosite":[ "cn" ] }, { "server":"block", "disable_cache":true, "geosite":[ "category-ads-all" ] }, { "outbound":"any", "server":"local_local" } ], "strategy":"ipv4_only" }, "inbounds":[ { "type":"tun", "tag":"tun-in", "interface_name":"singbox_tun", "inet4_address":"172.19.0.1/30", "inet6_address":"fdfe:dcba:9876::1/126", "mtu":9000, "auto_route":true, "strict_route":false, "stack":"gvisor", "sniff":true } ], "outbounds":[ { "type":"vless", "tag":"proxy", "server":"***", "server_port":443, "uuid":"**", "flow":"xtls-rprx-vision", "packet_encoding":"xudp", "tls":{ "enabled":true, "server_name":"itunes.apple.com", "insecure":false, "utls":{ "enabled":true, "fingerprint":"chrome" }, "reality":{ "enabled":true, "public_key":"***", "short_id":"" } } }, { "type":"direct", "tag":"direct" }, { "type":"block", "tag":"block" }, { "type":"dns", "tag":"dns_out" } ], "route":{ "auto_detect_interface":true, "rules":[ { "outbound":"dns_out", "inbound":[ "dns_in" ] }, { "outbound":"dns_out", "protocol":[ "dns" ] }, { "outbound":"block", "network":"udp", "port":[ 135, 137, 138, 139, 5353 ] }, { "outbound":"block", "ip_cidr":[ "224.0.0.0/3", "ff00::/8" ] }, { "outbound":"block", "source_ip_cidr":[ "224.0.0.0/3", "ff00::/8" ] }, { "outbound":"dns_out", "port":[ 53 ], "process_name":[ "wv2ray.exe", "v2ray.exe", "SagerNet.exe", "v2ray.exe", "v2ray.exe", "xray.exe", "wxray.exe", "clash-windows-amd64-v3.exe", "clash-windows-amd64.exe", "clash-windows-386.exe", "clash.exe", "Clash.Meta-windows-amd64-compatible.exe", "Clash.Meta-windows-amd64.exe", "Clash.Meta-windows-386.exe", "Clash.Meta.exe", "clash.exe", "hysteria-windows-amd64.exe", "hysteria-windows-386.exe", "hysteria.exe", "naiveproxy.exe", "naive.exe", "tuic-client.exe", "tuic.exe" ] }, { "outbound":"direct", "process_name":[ "wv2ray.exe", "v2ray.exe", "SagerNet.exe", "v2ray.exe", "v2ray.exe", "xray.exe", "wxray.exe", "clash-windows-amd64-v3.exe", "clash-windows-amd64.exe", "clash-windows-386.exe", "clash.exe", "Clash.Meta-windows-amd64-compatible.exe", "Clash.Meta-windows-amd64.exe", "Clash.Meta-windows-386.exe", "Clash.Meta.exe", "clash.exe", "hysteria-windows-amd64.exe", "hysteria-windows-386.exe", "hysteria.exe", "naiveproxy.exe", "naive.exe", "tuic-client.exe", "tuic.exe", "sing-box-client.exe", "sing-box.exe" ] }, { "outbound":"direct", "inbound":[ "socks", "http", "socks2", "http2" ], "protocol":[ "bittorrent", "tls", "http" ], "geosite":[ "adobe", "adobe-activation", "apple", "apple-cn", "cn", "google-cn", "microsoft", "msn", "private" ], "domain_keyword":[ "adblockplus.org", "adservice.google.com", "baiyunju.cc", "bitwarden.com", "bitwarden.net", "googleads.g.doubleclick.net", "letsencrypt.org", "safesugar.net" ] }, { "outbound":"direct", "inbound":[ "socks", "http", "socks2", "http2" ], "protocol":[ "bittorrent", "tls", "http" ], "geoip":[ "cn", "private" ], "ip_cidr":[ "10.20.30.0/24", "132.122.0.0/16" ] }, { "outbound":"block", "geosite":[ "category-ads-all" ] }, { "outbound":"proxy", "geosite":[ "gfw", "greatfire", "tld-!cn" ], "domain_keyword":[ "fundgz.1234567.com.cn", "hostloc.com", "rime.im", "todesk.com", "v2ex.com" ] }, { "outbound":"proxy", "geoip":[ "cloudflare", "cloudfront", "facebook", "fastly", "google", "netflix", "telegram", "twitter" ] }, { "outbound":"direct", "port_range":[ "0:65535" ] } ] } } ```
WoChen5770 commented 1 year ago

帮你格式化了下

屏幕截图 2023-06-05 235205

你需要有些sing-box 配置和流程的知识。

只有满足这条件的,使用你的DNS查询。没命中的,走第1个DNS,图上是 "tag":"remote", 的。

我看得出来你不熟悉sing-boxTUN模式时 DNS处理流程 配置文件作用等。

点击查看

{
    "log":{
        "level":"warn",
        "timestamp":true
    },
    "dns":{
        "servers":[
            {
                "tag":"remote",
                "address":"tcp://8.8.8.8",
                "detour":"proxy"
            },
            {
                "tag":"local",
                "address":"10.20.30.10",
                "detour":"direct"
            },
            {
                "tag":"block",
                "address":"rcode://success"
            },
            {
                "tag":"local_local",
                "address":"223.5.5.5",
                "detour":"direct"
            }
        ],
        "rules":[
            {
                "server":"local",
                "disable_cache":true,
                "geosite":[
                    "cn"
                ]
            },
            {
                "server":"block",
                "disable_cache":true,
                "geosite":[
                    "category-ads-all"
                ]
            },
            {
                "outbound":"any",
                "server":"local_local"
            }
        ],
        "strategy":"ipv4_only"
    },
    "inbounds":[
        {
            "type":"tun",
            "tag":"tun-in",
            "interface_name":"singbox_tun",
            "inet4_address":"172.19.0.1/30",
            "inet6_address":"fdfe:dcba:9876::1/126",
            "mtu":9000,
            "auto_route":true,
            "strict_route":false,
            "stack":"gvisor",
            "sniff":true
        }
    ],
    "outbounds":[
        {
            "type":"vless",
            "tag":"proxy",
            "server":"***",
            "server_port":443,
            "uuid":"**",
            "flow":"xtls-rprx-vision",
            "packet_encoding":"xudp",
            "tls":{
                "enabled":true,
                "server_name":"itunes.apple.com",
                "insecure":false,
                "utls":{
                    "enabled":true,
                    "fingerprint":"chrome"
                },
                "reality":{
                    "enabled":true,
                    "public_key":"***",
                    "short_id":""
                }
            }
        },
        {
            "type":"direct",
            "tag":"direct"
        },
        {
            "type":"block",
            "tag":"block"
        },
        {
            "type":"dns",
            "tag":"dns_out"
        }
    ],
    "route":{
        "auto_detect_interface":true,
        "rules":[
            {
                "outbound":"dns_out",
                "inbound":[
                    "dns_in"
                ]
            },
            {
                "outbound":"dns_out",
                "protocol":[
                    "dns"
                ]
            },
            {
                "outbound":"block",
                "network":"udp",
                "port":[
                    135,
                    137,
                    138,
                    139,
                    5353
                ]
            },
            {
                "outbound":"block",
                "ip_cidr":[
                    "224.0.0.0/3",
                    "ff00::/8"
                ]
            },
            {
                "outbound":"block",
                "source_ip_cidr":[
                    "224.0.0.0/3",
                    "ff00::/8"
                ]
            },
            {
                "outbound":"dns_out",
                "port":[
                    53
                ],
                "process_name":[
                    "wv2ray.exe",
                    "v2ray.exe",
                    "SagerNet.exe",
                    "v2ray.exe",
                    "v2ray.exe",
                    "xray.exe",
                    "wxray.exe",
                    "clash-windows-amd64-v3.exe",
                    "clash-windows-amd64.exe",
                    "clash-windows-386.exe",
                    "clash.exe",
                    "Clash.Meta-windows-amd64-compatible.exe",
                    "Clash.Meta-windows-amd64.exe",
                    "Clash.Meta-windows-386.exe",
                    "Clash.Meta.exe",
                    "clash.exe",
                    "hysteria-windows-amd64.exe",
                    "hysteria-windows-386.exe",
                    "hysteria.exe",
                    "naiveproxy.exe",
                    "naive.exe",
                    "tuic-client.exe",
                    "tuic.exe"
                ]
            },
            {
                "outbound":"direct",
                "process_name":[
                    "wv2ray.exe",
                    "v2ray.exe",
                    "SagerNet.exe",
                    "v2ray.exe",
                    "v2ray.exe",
                    "xray.exe",
                    "wxray.exe",
                    "clash-windows-amd64-v3.exe",
                    "clash-windows-amd64.exe",
                    "clash-windows-386.exe",
                    "clash.exe",
                    "Clash.Meta-windows-amd64-compatible.exe",
                    "Clash.Meta-windows-amd64.exe",
                    "Clash.Meta-windows-386.exe",
                    "Clash.Meta.exe",
                    "clash.exe",
                    "hysteria-windows-amd64.exe",
                    "hysteria-windows-386.exe",
                    "hysteria.exe",
                    "naiveproxy.exe",
                    "naive.exe",
                    "tuic-client.exe",
                    "tuic.exe",
                    "sing-box-client.exe",
                    "sing-box.exe"
                ]
            },
            {
                "outbound":"direct",
                "inbound":[
                    "socks",
                    "http",
                    "socks2",
                    "http2"
                ],
                "protocol":[
                    "bittorrent",
                    "tls",
                    "http"
                ],
                "geosite":[
                    "adobe",
                    "adobe-activation",
                    "apple",
                    "apple-cn",
                    "cn",
                    "google-cn",
                    "microsoft",
                    "msn",
                    "private"
                ],
                "domain_keyword":[
                    "adblockplus.org",
                    "adservice.google.com",
                    "baiyunju.cc",
                    "bitwarden.com",
                    "bitwarden.net",
                    "googleads.g.doubleclick.net",
                    "letsencrypt.org",
                    "safesugar.net"
                ]
            },
            {
                "outbound":"direct",
                "inbound":[
                    "socks",
                    "http",
                    "socks2",
                    "http2"
                ],
                "protocol":[
                    "bittorrent",
                    "tls",
                    "http"
                ],
                "geoip":[
                    "cn",
                    "private"
                ],
                "ip_cidr":[
                    "10.20.30.0/24",
                    "132.122.0.0/16"
                ]
            },
            {
                "outbound":"block",
                "geosite":[
                    "category-ads-all"
                ]
            },
            {
                "outbound":"proxy",
                "geosite":[
                    "gfw",
                    "greatfire",
                    "tld-!cn"
                ],
                "domain_keyword":[
                    "fundgz.1234567.com.cn",
                    "hostloc.com",
                    "rime.im",
                    "todesk.com",
                    "v2ex.com"
                ]
            },
            {
                "outbound":"proxy",
                "geoip":[
                    "cloudflare",
                    "cloudfront",
                    "facebook",
                    "fastly",
                    "google",
                    "netflix",
                    "telegram",
                    "twitter"
                ]
            },
            {
                "outbound":"direct",
                "port_range":[
                    "0:65535"
                ]
            }
        ]
    }
}

可能是我没表达清楚? 我这个配置就是国内域名解析用local dns吧,但是我访问国内域名时,并没有通过我设置的local dns去解析域名。那个local dns是我部署的一个dns 服务器,我能通过日志查看到 当使用tun模式时,没有dns 请求过来

WoChen5770 commented 1 year ago

意思就是 tun模式下 国内域名没有走 自定义国内域名解析dns服务器(v2ray默认是阿里的223)。这个问题明天我再重现一下试试

chika0801 commented 1 year ago

我这个配置就是国内域名解析用local dns吧,但是我访问国内域名时,并没有通过我设置的local dns去解析域名。那个local dns是我部署的一个dns 服务器,我能通过日志查看到 当使用tun模式时,没有dns 请求过来

你把日志开成Debug 访问国内域名如baidu.com 。你看看日志或帖上来我们看看

WoChen5770 commented 1 year ago

我这个配置就是国内域名解析用local dns吧,但是我访问国内域名时,并没有通过我设置的local dns去解析域名。那个local dns是我部署的一个dns 服务器,我能通过日志查看到 当使用tun模式时,没有dns 请求过来

你把日志开成Debug 访问国内域名如baidu.com 。你看看日志或帖上来我们看看

我找到原因了,10.20.30.10是zerotier分配给本机的ip,应该是zerotier的路由规则和tun有冲突

WoChen5770 commented 1 year ago

我这个配置就是国内域名解析用local dns吧,但是我访问国内域名时,并没有通过我设置的local dns去解析域名。那个local dns是我部署的一个dns 服务器,我能通过日志查看到 当使用tun模式时,没有dns 请求过来

你把日志开成Debug 访问国内域名如baidu.com 。你看看日志或帖上来我们看看

另外 dns地址是不支持 doh dot吗,设置成doh dot会启动失败 启动服务(2023/6/6 11:25:32)... FATAL[0000] create service: parse route options: parse dns server[local]: missing address_resolver { "tag": "local", "address": "tls://dot.pub", "detour": "direct" }

chika0801 commented 1 year ago

我这个配置就是国内域名解析用local dns吧,但是我访问国内域名时,并没有通过我设置的local dns去解析域名。那个local dns是我部署的一个dns 服务器,我能通过日志查看到 当使用tun模式时,没有dns 请求过来

你把日志开成Debug 访问国内域名如baidu.com 。你看看日志或帖上来我们看看

另外 dns地址是不支持 doh dot吗,设置成doh dot会启动失败 启动服务(2023/6/6 11:25:32)... �[31mFATAL�[0m[0000] create service: parse route options: parse dns server[local]: missing address_resolver { "tag": "local", "address": "tls://dot.pub", "detour": "direct" }

支持你要不看sb文档写法,https://github.com/2dust/v2rayN/issues/3942#issuecomment-1576632967 这里给你的链接里的示例其实就是写好了的。

WoChen5770 commented 1 year ago

我这个配置就是国内域名解析用local dns吧,但是我访问国内域名时,并没有通过我设置的local dns去解析域名。那个local dns是我部署的一个dns 服务器,我能通过日志查看到 当使用tun模式时,没有dns 请求过来

你把日志开成Debug 访问国内域名如baidu.com 。你看看日志或帖上来我们看看

另外 dns地址是不支持 doh dot吗,设置成doh dot会启动失败 启动服务(2023/6/6 11:25:32)... �[31mFATAL�[0m[0000] create service: parse route options: parse dns server[local]: missing address_resolver { "tag": "local", "address": "tls://dot.pub", "detour": "direct" }

支持你要不看sb文档写法,#3942 (comment) 这里给你的链接里的示例其实就是写好了的。

好的,感谢解惑