终端在ipv4环境下时,direct流量总是优先使用AAAA解析得到的IPV6地址,导致国内网站无法正常连接
Open
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 38.2k
- Forks
- 4.6k
- Avg merge
- 19d 15h
- Merged PRs (30d)
- 1
Description
操作系统
其他
系统版本
android,macos,windows全都可以复现
安装类型
其他
如果您使用图形客户端程序,请提供该程序版本。
1.14.0-beta17 sfm/sfa/sfw
版本
1.14.0-beta17
描述
前提条件是tun中adress选项为"172.18.0.1/30", "fdfe:dcba:9876::1/126"时
- 当我的网络环境只有ipv4时,即使我在dns.strategy中设置prefer_ipv4,direct流量依然返回AAAA解析结果,导致连接失败,只有将dns.srategy设置为ipv4_only时,或者将tun中的ipv6地址删除,才会正确的使用A解析。
以下是错误日志内容
connection: open connection to [240e:950:400::7ce2:4824]:443 using outbound/direct[DIRECT]: dial en0 (5): dial tcp [240e:950:400::7ce2:4824]:443: connect: no route to host
- 当我将tun中的IPV6地址删除,在ipv6环境下derect流量可以正常连接,但部署在ipv6服务器上的Naiveproxy节点无法连接,除了naiveproxy之外其他的协议(目前我测试过的有anytls, vless, tuic, hysteria_v1, hysteria_v2, shadowsocks+shadowtls)可正常连接
重现方式
除outbound之外的配置片段
{
"log": {
"level": "debug",
"timestamp": true
},
"dns": {
"servers": [
{
"type": "udp",
"tag": "local",
"server": "223.5.5.5"
},
{
"type": "https",
"tag": "remote",
"detour": "Node_Selected",
"server": "1.1.1.1"
},
{
"type": "fakeip",
"tag": "fakeip",
"inet4_range": "198.18.0.0/15",
"inet6_range": "fc00::/18"
}
],
"rules": [
{
"action": "evaluate",
"server": "remote"
},
{
"match_response": true,
"rule_set": ["adguard-dns-filter"],
"action": "reject"
},
{
"type": "logical",
"mode": "and",
"rules": [
{
"match_response": true,
"rule_set": "fakeip-filter"
},
{
"match_response": true,
"rule_set": [
"geosite-cn",
"geosite-private",
"geosite-bilibili-cdn",
"geosite-bilibili-game",
"geosite-bilibili",
"geosite-bilibili2",
"china-list",
"china-list-apple-cn",
"china-list-google-cn",
"geosite-cn"
]
}
],
"action": "route",
"server": "local"
},
{
"match_response": true,
"rule_set": "fakeip-filter",
"action": "route",
"server": "remote"
},
{
"type": "logical",
"mode": "or",
"rules": [
{
"match_response": true,
"rule_set": [
"geosite-discord",
"geosite-github",
"geosite-gitlab",
"geosite-bilibili@!cn",
"geosite-bilibili-cdn@!cn",
"geosite-geolocation-!cn",
"geosite-category-porn",
"gfwlist"
],
"domain_suffix": [
"services.googleapis.cn",
"googleapis.cn",
"googleapis.com",
"gstatic.com",
"googleusercontent.com",
"play.googleapis.com",
"play-fe.googleapis.com",
"android.clients.google.com",
"xn--ngstr-lra8j.com"
],
"package_name": ["com.android.vending"]
},
{
"type": "logical",
"mode": "and",
"rules": [
{
"match_response": true,
"query_type": ["A", "AAAA"]
},
{
"rule_set": "geosite-cn",
"invert": true
}
]
}
],
"action": "route",
"server": "fakeip"
},
{
"match_response": true,
"domain_regex": [
"^r+[0-9]+(---|\\.)sn-(2x3|ni5|j5o)\\w{5}\\.xn--ngstr-lra8j\\.com$"
],
"rule_set": [
"geosite-private",
"geosite-bilibili-cdn",
"geosite-bilibili-game",
"geosite-bilibili",
"geosite-bilibili2",
"china-list",
"china-list-apple-cn",
"china-list-google-cn",
"geosite-cn"
],
"action": "route",
"server": "local"
}
],
"final": "remote",
"strategy": "prefer_ipv4",
"cache_capacity": 8192,
"optimistic": {
"enabled": true,
"timeout": "3d"
}
},
"http_clients": [
{
"tag": "direct-http",
"version": 2,
"stream_receive_window": 0,
"connection_receive_window": 0
}
],
"inbounds": [
{
"type": "tun",
"tag": "tun-in",
"mtu": 9000,
"address": ["172.19.0.1/30", "fdfe:dcba:9876::1/126"],
"auto_route": true,
"strict_route": true,
"dns_mode": "hijack",
"stack": "mixed"
},
{
"type": "mixed",
"tag": "mixed-in",
"listen": "127.0.0.1",
"listen_port": 7890
},
{
"type": "http",
"tag": "http-in",
"listen": "127.0.0.1",
"listen_port": 7891
},
{
"type": "socks",
"tag": "socks-in",
"listen": "127.0.0.1",
"listen_port": 7892
},
{
"type": "redirect",
"tag": "redirect-in",
"listen_port": 7893
}
],
"outbounds": [
{
"type": "direct",
"tag": "DIRECT"
},
{
"type": "naive",
"tag": "NV01-US",
"server": "example.com",
"server_port": 443,
"username": "user",
"password": "password",
"insecure_concurrency": 0,
"extra_headers": {},
"udp_over_tcp": false,
"quic": true,
"quic_congestion_control": "bbr",
"tls": {
"enabled": true,
"server_name": "example.com"
}
},
{
"type": "selector",
"tag": "Node_Selected",
"outbounds": [
"Auto_node",
"DIRECT",
"NV01-US"
],
"default": "Auto_node",
"interrupt_exist_connections": true
},
{
"type": "urltest",
"tag": "Auto_node",
"outbounds": [
"NV01-US"
],
"url": "https://cp.cloudflare.com",
"interval": "5m0s",
"tolerance": 50,
"idle_timeout": "30m0s",
"interrupt_exist_connections": true
}
],
"route": {
"rules": [
{
"action": "sniff"
},
{
"protocol": "dns",
"action": "hijack-dns"
},
{
"ip_is_private": true,
"action": "route",
"outbound": "DIRECT"
},
{
"clash_mode": "Direct",
"action": "route",
"outbound": "DIRECT"
},
{
"clash_mode": "Global",
"action": "route",
"outbound": "Node_Selected"
},
{
"rule_set": ["adguard-dns-filter"],
"action": "reject",
"method": "default",
"no_drop": false
},
{
"clash_mode": "Rule",
"domain_suffix": [
"services.googleapis.cn",
"googleapis.cn",
"googleapis.com",
"gstatic.com",
"googleusercontent.com",
"play.googleapis.com",
"play-fe.googleapis.com",
"android.clients.google.com",
"xn--ngstr-lra8j.com"
],
"action": "route",
"outbound": "Node_Selected"
},
{
"clash_mode": "Rule",
"package_name": ["com.android.vending"],
"action": "route",
"outbound": "Node_Selected"
},
{
"clash_mode": "Rule",
"rule_set": [
"geosite-discord",
"geosite-github",
"geosite-gitlab",
"geosite-bilibili@!cn",
"geosite-bilibili-cdn@!cn",
"geosite-geolocation-!cn",
"geosite-category-porn",
"gfwlist"
],
"action": "route",
"outbound": "Node_Selected"
},
{
"clash_mode": "Rule",
"domain_suffix": [".cn"],
"domain_regex": [
"^r+[0-9]+(---|\\.)sn-(2x3|ni5|j5o)\\w{5}\\.xn--ngstr-lra8j\\.com$"
],
"action": "route",
"outbound": "DIRECT"
},
{
"clash_mode": "Rule",
"rule_set": [
"geosite-private",
"geosite-bilibili-cdn",
"geosite-bilibili-game",
"geosite-bilibili",
"geosite-bilibili2",
"china-list",
"china-list-apple-cn",
"china-list-google-cn",
"geosite-cn",
"geoip-cn"
],
"action": "route",
"outbound": "DIRECT"
}
],
"rule_set": [
{
"type": "remote",
"tag": "fakeip-filter",
"url": "https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/fakeip-filter.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "china-list",
"url": "https://cdn.jsdelivr.net/gh/Dreista/sing-box-rule-set-cn@rule-set/accelerated-domains.china.conf.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "china-list-apple-cn",
"url": "https://cdn.jsdelivr.net/gh/Dreista/sing-box-rule-set-cn@rule-set/apple.china.conf.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "china-list-google-cn",
"url": "https://cdn.jsdelivr.net/gh/Dreista/sing-box-rule-set-cn@rule-set/google.china.conf.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "gfwlist",
"url": "https://cdn.jsdelivr.net/gh/Dreista/sing-box-rule-set-cn@rule-set/gfwlist.txt.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-cn",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geosite@rule-set/geosite-cn.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-private",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-private.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-discord",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geosite@rule-set/geosite-discord.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-github",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geosite@rule-set/geosite-github.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-gitlab",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geosite@rule-set/geosite-gitlab.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-bilibili-cdn",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geosite@rule-set/geosite-bilibili-cdn.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-bilibili-cdn@!cn",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geosite@rule-set/geosite-bilibili-cdn@!cn.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-bilibili-game",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geosite@rule-set/geosite-bilibili-game.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-bilibili",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geosite@rule-set/geosite-bilibili.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-bilibili2",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geosite@rule-set/geosite-bilibili2.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-bilibili@!cn",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geosite@rule-set/geosite-bilibili@!cn.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geoip-cn",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geoip@rule-set/geoip-cn.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-geolocation-!cn",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geosite@rule-set/geosite-geolocation-!cn.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "adguard-dns-filter",
"url": "https://cdn.jsdelivr.net/gh/Dreista/sing-box-rule-set-cn@rule-set/filter.txt.srs",
"update_interval": "24h0m0s"
},
{
"type": "remote",
"tag": "geosite-category-porn",
"url": "https://cdn.jsdelivr.net/gh/SagerNet/sing-geosite@rule-set/geosite-category-porn.srs",
"update_interval": "24h0m0s"
}
],
"final": "Node_Selected",
"auto_detect_interface": true,
"default_domain_resolver": "local",
"default_http_client": "direct-http"
},
"experimental": {
"cache_file": {
"enabled": true,
"path": "cache.db",
"store_dns": true,
"store_fakeip": true
},
"clash_api": {
"external_controller": "127.0.0.1:9090",
"default_mode": "Rule"
}
}
}
日志
DEBUG[0011] [2434659408 1ms] dns: exchange www.baidu.com. IN AAAA
DEBUG[0011] [2434659408 1ms] dns: match[0] => evaluate(remote)
DEBUG[0011] [2434659408 1ms] dns: cached www.baidu.com NOERROR 11
INFO[0011] [2434659408 1ms] dns: cached CNAME www.baidu.com. 11 IN CNAME www.a.shifen.com.
INFO[0011] [2434659408 1ms] dns: cached CNAME www.a.shifen.com. 11 IN CNAME www.wshifen.com.
INFO[0011] [2434659408 1ms] dns: cached SOA wshifen.com. 11 IN SOA ns1.wshifen.com. baidu_dns_master.baidu.com. 2608190001 60 30 2592000 3600
DEBUG[0011] [2434659408 1ms] dns: match[5] domain_regex=^r+[0-9]+(---|\.)sn-(2x3|ni5|j5o)\w{5}\.xn--ngstr-lra8j\.com$ rule_set=[geosite-private geosite-bilibili-cdn geosite-bilibili-game geosite-bilibili geosite-bilibili2 china-list china-list-apple-cn china-list-google-cn geosite-cn] => route(local)
DEBUG[0011] [2434659408 1ms] dns: cached www.baidu.com NOERROR 5
INFO[0011] [2434659408 1ms] dns: cached CNAME www.baidu.com. 5 IN CNAME www.a.shifen.com.
INFO[0011] [2434659408 1ms] dns: cached AAAA www.a.shifen.com. 5 IN AAAA 240e:ff:e020:98c:0:ff:b061:c306
INFO[0011] [2434659408 1ms] dns: cached AAAA www.a.shifen.com. 5 IN AAAA 240e:ff:e020:99b:0:ff:b099:cff1
INFO[0011] [1528556425 0ms] inbound/tun[tun-in]: inbound DNS packet from 172.19.0.1:33459
INFO[0011] [1528556425 0ms] router: found process path: /Applications/Microsoft Edge Dev.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/153.0.4224.0/Helpers/Microsoft Edge Helper.app/Contents/MacOS/Microsoft Edge Helper, user: testuser
DEBUG[0011] [1528556425 0ms] dns: exchange www.baidu.com. IN A
DEBUG[0011] [1528556425 0ms] dns: match[0] => evaluate(remote)
DEBUG[0011] [1528556425 0ms] dns: cached www.baidu.com NOERROR 27
INFO[0011] [1528556425 0ms] dns: cached CNAME www.baidu.com. 27 IN CNAME www.a.shifen.com.
INFO[0011] [1528556425 0ms] dns: cached CNAME www.a.shifen.com. 27 IN CNAME www.wshifen.com.
INFO[0011] [1528556425 0ms] dns: cached A www.wshifen.com. 27 IN A 103.235.46.102
INFO[0011] [1528556425 0ms] dns: cached A www.wshifen.com. 27 IN A 103.235.46.115
DEBUG[0011] [1528556425 0ms] dns: match[5] domain_regex=^r+[0-9]+(---|\.)sn-(2x3|ni5|j5o)\w{5}\.xn--ngstr-lra8j\.com$ rule_set=[geosite-private geosite-bilibili-cdn geosite-bilibili-game geosite-bilibili geosite-bilibili2 china-list china-list-apple-cn china-list-google-cn geosite-cn] => route(local)
DEBUG[0011] [1528556425 0ms] dns: cached www.baidu.com NOERROR 95
INFO[0011] [1528556425 1ms] dns: cached CNAME www.baidu.com. 95 IN CNAME www.a.shifen.com.
INFO[0011] [1528556425 1ms] dns: cached A www.a.shifen.com. 95 IN A 183.2.172.177
INFO[0011] [2767800174 0ms] router: found process path: /Applications/Microsoft Edge Dev.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/153.0.4224.0/Helpers/Microsoft Edge Helper.app/Contents/MacOS/Microsoft Edge Helper, user: testuser
DEBUG[0011] [2767800174 0ms] router: pre-match[0] => sniff
INFO[0011] [379752247 0ms] router: found process path: /Applications/Microsoft Edge Dev.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/153.0.4224.0/Helpers/Microsoft Edge Helper.app/Contents/MacOS/Microsoft Edge Helper, user: testuser
DEBUG[0011] [379752247 0ms] router: pre-match[0] => sniff
INFO[0011] [3528697645 0ms] router: found process path: /Applications/Microsoft Edge Dev.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/153.0.4224.0/Helpers/Microsoft Edge Helper.app/Contents/MacOS/Microsoft Edge Helper, user: testuser
DEBUG[0011] [3528697645 0ms] router: pre-match[0] => sniff
INFO[0011] [435858707 0ms] inbound/tun[tun-in]: inbound connection from [fdfe:dcba:9876::1]:52054
INFO[0011] [435858707 0ms] inbound/tun[tun-in]: inbound connection to [240e:ff:e020:98c:0:ff:b061:c306]:443
INFO[0011] [435858707 0ms] router: found process path: /Applications/Microsoft Edge Dev.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/153.0.4224.0/Helpers/Microsoft Edge Helper.app/Contents/MacOS/Microsoft Edge Helper, user: testuser
DEBUG[0011] [435858707 0ms] router: match[0] => sniff
INFO[0011] [1975870838 0ms] inbound/tun[tun-in]: inbound connection from [fdfe:dcba:9876::1]:52055
INFO[0011] [1975870838 0ms] inbound/tun[tun-in]: inbound connection to [240e:ff:e020:98c:0:ff:b061:c306]:443
INFO[0011] [2891685502 0ms] inbound/tun[tun-in]: inbound connection from [fdfe:dcba:9876::1]:52056
INFO[0011] [1975870838 0ms] router: found process path: /Applications/Microsoft Edge Dev.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/153.0.4224.0/Helpers/Microsoft Edge Helper.app/Contents/MacOS/Microsoft Edge Helper, user: testuser
INFO[0011] [2891685502 0ms] inbound/tun[tun-in]: inbound connection to [240e:950:400::7ce2:4824]:443
DEBUG[0011] [1975870838 0ms] router: match[0] => sniff
INFO[0011] [2891685502 0ms] router: found process path: /Applications/Microsoft Edge Dev.app/Contents/Frameworks/Microsoft Edge Framework.framework/Versions/153.0.4224.0/Helpers/Microsoft Edge Helper.app/Contents/MacOS/Microsoft Edge Helper, user: testuser
DEBUG[0011] [2891685502 0ms] router: match[0] => sniff
DEBUG[0011] [435858707 1ms] router: sniffed protocol: tls, domain: www.baidu.com
DEBUG[0011] [1975870838 1ms] router: sniffed protocol: tls, domain: www.baidu.com
DEBUG[0011] [2891685502 1ms] router: sniffed protocol: tls, domain: pss.bdstatic.com
DEBUG[0011] [435858707 1ms] router: match[10] clash_mode=Rule rule_set=[geosite-private geosite-bilibili-cdn geosite-bilibili-game geosite-bilibili geosite-bilibili2 china-list china-list-apple-cn china-list-google-cn geosite-cn geoip-cn] => route(DIRECT)
DEBUG[0011] [1975870838 1ms] router: match[10] clash_mode=Rule rule_set=[geosite-private geosite-bilibili-cdn geosite-bilibili-game geosite-bilibili geosite-bilibili2 china-list china-list-apple-cn china-list-google-cn geosite-cn geoip-cn] => route(DIRECT)
INFO[0011] [435858707 2ms] outbound/direct[DIRECT]: outbound connection to [240e:ff:e020:98c:0:ff:b061:c306]:443
INFO[0011] [1975870838 2ms] outbound/direct[DIRECT]: outbound connection to [240e:ff:e020:98c:0:ff:b061:c306]:443
DEBUG[0011] [2891685502 2ms] router: match[10] clash_mode=Rule rule_set=[geosite-private geosite-bilibili-cdn geosite-bilibili-game geosite-bilibili geosite-bilibili2 china-list china-list-apple-cn china-list-google-cn geosite-cn geoip-cn] => route(DIRECT)
ERROR[0011] [1975870838 2ms] connection: open connection to [240e:ff:e020:98c:0:ff:b061:c306]:443 using outbound/direct[DIRECT]: dial en0 (5): dial tcp [240e:ff:e020:98c:0:ff:b061:c306]:443: connect: no route to host
INFO[0011] [2891685502 2ms] outbound/direct[DIRECT]: outbound connection to [240e:950:400::7ce2:4824]:443
ERROR[0011] [435858707 2ms] connection: open connection to [240e:ff:e020:98c:0:ff:b061:c306]:443 using outbound/direct[DIRECT]: dial en0 (5): dial tcp [240e:ff:e020:98c:0:ff:b061:c306]:443: connect: no route to host
ERROR[0011] [2891685502 2ms] connection: open connection to [240e:950:400::7ce2:4824]:443 using outbound/direct[DIRECT]: dial en0 (5): dial tcp [240e:950:400::7ce2:4824]:443: connect: no route to host
支持我们
- 我已经 赞助
完整性要求
- 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
- 我保证提供了可以在本地重现该问题的服务器、客户端配置文件与流程,而不是一个脱敏的复杂客户端配置文件。
- 我保证提供了可用于重现我报告的错误的最简配置,而不是依赖远程服务器、TUN、图形界面客户端或者其他闭源软件。
- 我保证提供了完整的配置文件与日志,而不是出于对自身智力的自信而仅提供了部分认为有用的部分。
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the direct-outbound IPv6 selection with the supplied DNS strategy and TUN address configuration, then inspect the DNS resolution and direct dialing entry points. Compare behavior with prefer_ipv4, ipv4_only, and without the TUN IPv6 address; done means direct traffic uses a reachable address in IPv4-only networks while IPv6 direct and Naiveproxy connections continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100