SagerNet / SagerNet/sing-box

默认情况下不会对53端口进行dns劫持

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

Nobody has claimed this yet.

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

Description

操作系统

Android

系统版本

Android12

安装类型

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

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

1.14.0-beta.1

版本

描述

默认情况下不会对53端口额外进行dns劫持,针对53端口,需要额外显式配置 hijack-dns 路由规则。

重现方式

手机上使用termux执行dig www.cloudflare.com。预期应该返回fakeip,由于没劫持导致返回的是realip。
{
"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"
},
{
"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
}
}
}

日志
INFO[0018] [2142558592 0ms] inbound/tun[tun]: inbound packet connection from 172.18.0.1:60296
INFO[0018] [2142558592 0ms] inbound/tun[tun]: inbound packet connection to 8.8.8.8:53
INFO[0018] [2142558592 0ms] router: found package name: com.termux
DEBUG[0018] [2142558592 0ms] router: match[0] => sniff
DEBUG[0018] [2142558592 1ms] router: sniffed packet protocol: dns
DEBUG[0018] [2142558592 1ms] router: match[1] => route-options(udp-connect)
INFO[0018] [2142558592 1ms] outbound/direct[direct]: outbound packet connection to 8.8.8.8:53

这是在termux上的dns查询结果,预期应该返回fakeip
dig www.cloudflare.com

; <<>> DiG 9.20.23 <<>> www.cloudflare.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31708
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.cloudflare.com.            IN      A

;; ANSWER SECTION:
www.cloudflare.com.     300     IN      A      104.16.124.96
www.cloudflare.com.     300     IN      A      104.16.123.96

;; Query time: 88 msec
;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP)
支持我们
完整性要求
  • 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
  • 我保证提供了可以在本地重现该问题的服务器、客户端配置文件与流程,而不是一个脱敏的复杂客户端配置文件。
  • 我保证提供了可用于重现我报告的错误的最简配置,而不是依赖远程服务器、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 with TUN inbound handling for UDP packets to port 53 and the routing behavior around the explicitly mentioned hijack-dns rule. Reproduce the supplied Android/Termux configuration with dig, then verify whether the default path produces the expected fakeip result without that rule.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, go
Domain
mobile-dev, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.