SagerNet / SagerNet/sing-box

SFA-1.14.0-alpha.43,配置client_subnet导致dns缓存失效

Open
#4,291 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
38.2k
Forks
4.6k
Avg merge
19d 15h
Merged PRs (30d)
1

Description

操作系统

Android

系统版本

Android12

安装类型

sing-box for Android 图形客户端程序

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

1.14.0-alpha.43

版本

描述

配置client_subnet导致dns缓存失效

重现方式

使用浏览器打开 https://www.cloudflare.com/cdn-cgi/trace
{
"log": {
"level": "info"
},
"dns": {
"servers": [
{
"type": "https",
"tag": "alidns",
"server": "223.5.5.5"
},
{
"type": "fakeip",
"tag": "fakeip",
"inet4_range": "198.18.0.0/15"
}
],
"rules": [
{
"query_type": "HTTPS",
"action": "reject"
},
{
"action": "evaluate",
"server": "alidns",
"client_subnet": "1.0.1.0/24"
},
{
"query_type": "A",
"server": "fakeip"
}
],
"final": "alidns",
"strategy": "ipv4_only",
"optimistic": true
},
"inbounds": [
{
"type": "tun",
"tag": "tun",
"address": "172.18.0.1/30",
"auto_route": true
}
],
"outbounds": [
{
"type": "direct",
"tag": "direct",
"domain_resolver": {
"server": "alidns",
"strategy": "ipv4_only"
}
}
],
"route": {
"rules": [
{
"action": "sniff"
},
{
"action": "route-options",
"udp_connect": true
}
],
"final": "direct",
"auto_detect_interface": true,
"default_domain_resolver": "alidns"
},
"experimental": {
"cache_file": {
"enabled": true,
"store_fakeip": true,
"store_dns": true
}
}
}

日志
这是dns规则配置client_subnet时的查询日志
INFO[0012] [1784911861 0ms] inbound/tun[tun]: inbound DNS packet connection from 172.18.0.1:18815
DEBUG[0012] [1784911861 0ms] dns: exchange www.cloudflare.com. IN A
DEBUG[0012] [1784911861 0ms] dns: match[1] => evaluate(alidns,client-subnet=1.0.1.0/24)
DEBUG[0012] [1784911861 61ms] dns: exchanged www.cloudflare.com NOERROR 85
INFO[0012] [1784911861 61ms] dns: exchanged A www.cloudflare.com. 85 IN A 104.16.123.96
INFO[0012] [1784911861 61ms] dns: exchanged A www.cloudflare.com. 85 IN A 104.16.124.96
INFO[0012] [1784911861 61ms] dns: exchanged OPT OPT PSEUDOSECTION: EDNS: version 0 flags: udp: 1232 SUBNET: 1.0.1.0/24/24
DEBUG[0012] [1784911861 61ms] dns: match[2] query_type=A => route(fakeip)
DEBUG[0012] [1784911861 62ms] dns: exchanged www.cloudflare.com NOERROR 600
INFO[0012] [1784911861 62ms] dns: exchanged A www.cloudflare.com. 600 IN A 198.18.0.13
INFO[0110] [331515328 0ms] inbound/tun[tun]: inbound DNS packet connection from 172.18.0.1:51038
DEBUG[0110] [331515328 0ms] dns: exchange www.cloudflare.com. IN A
DEBUG[0110] [331515328 0ms] dns: match[1] => evaluate(alidns,client-subnet=1.0.1.0/24)
DEBUG[0110] [331515328 52ms] dns: exchanged www.cloudflare.com NOERROR 284
INFO[0110] [331515328 52ms] dns: exchanged A www.cloudflare.com. 284 IN A 104.16.124.96
INFO[0110] [331515328 52ms] dns: exchanged A www.cloudflare.com. 284 IN A 104.16.123.96
INFO[0110] [331515328 52ms] dns: exchanged OPT OPT PSEUDOSECTION: EDNS: version 0 flags: udp: 1232 SUBNET: 1.0.1.0/24/24
DEBUG[0110] [331515328 52ms] dns: match[2] query_type=A => route(fakeip)
DEBUG[0110] [331515328 52ms] dns: exchanged www.cloudflare.com NOERROR 600
INFO[0110] [331515328 52ms] dns: exchanged A www.cloudflare.com. 600 IN A 198.18.0.13

这是dns规则没配置client_subnet时的查询日志
INFO[0006] [1191483060 0ms] inbound/tun[tun]: inbound DNS packet connection from 172.18.0.1:35548
DEBUG[0006] [1191483060 0ms] dns: exchange www.cloudflare.com. IN A
DEBUG[0006] [1191483060 0ms] dns: match[1] => evaluate(alidns)
DEBUG[0007] [1191483060 40ms] dns: exchanged www.cloudflare.com NOERROR 272
INFO[0007] [1191483060 40ms] dns: exchanged A www.cloudflare.com. 272 IN A 104.16.123.96
INFO[0007] [1191483060 40ms] dns: exchanged A www.cloudflare.com. 272 IN A 104.16.124.96
DEBUG[0007] [1191483060 40ms] dns: match[2] query_type=A => route(fakeip)
DEBUG[0007] [1191483060 51ms] dns: exchanged www.cloudflare.com NOERROR 600
INFO[0007] [1191483060 51ms] dns: exchanged A www.cloudflare.com. 600 IN A 198.18.0.6
INFO[0024] [2730686318 0ms] inbound/tun[tun]: inbound DNS packet connection from 172.18.0.1:6030
DEBUG[0024] [2730686318 0ms] dns: exchange www.cloudflare.com. IN A
DEBUG[0024] [2730686318 0ms] dns: match[1] => evaluate(alidns)
DEBUG[0024] [2730686318 0ms] dns: cached www.cloudflare.com NOERROR 254
INFO[0024] [2730686318 0ms] dns: cached A www.cloudflare.com. 254 IN A 104.16.123.96
INFO[0024] [2730686318 0ms] dns: cached A www.cloudflare.com. 254 IN A 104.16.124.96
INFO[0024] [2730686318 0ms] dns: cached OPT OPT PSEUDOSECTION: EDNS: version 0 flags: udp: 1232
DEBUG[0024] [2730686318 0ms] dns: match[2] query_type=A => route(fakeip)
DEBUG[0024] [2730686318 0ms] dns: exchanged www.cloudflare.com NOERROR 600
INFO[0024] [2730686318 0ms] dns: exchanged A www.cloudflare.com. 600 IN A 198.18.0.6
支持我们
完整性要求
  • 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
  • 我保证提供了可以在本地重现该问题的服务器、客户端配置文件与流程,而不是一个脱敏的复杂客户端配置文件。
  • 我保证提供了可用于重现我报告的错误的最简配置,而不是依赖远程服务器、TUN、图形界面客户端或者其他闭源软件。
  • 我保证提供了完整的配置文件与日志,而不是出于对自身智力的自信而仅提供了部分认为有用的部分。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the supplied DNS rules, client_subnet setting, cache_file options, and query logs. Compare the cache behavior between the configurations with and without client_subnet, then trace the DNS cache path from the evaluate rule. Done means repeated www.cloudflare.com queries reuse the cached result while preserving the configured client subnet behavior.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.