linux系统下local dns detour direct导致代理请求地址错误

Open
#1,681 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
go, linux

Research direction

Reproduce the Linux chain of ss inbound, local DNS with a direct detour, and socks outbound with DNS caching disabled, then trace how the local DNS request context reaches the direct outbound. Compare the Linux path with the Windows local-DNS behavior and verify that the proxied destination remains unchanged while the logs show the intended DNS request.

Written by the indexing model from the issue text.

Description

bug
操作系统

Linux

系统版本

任何版本都是出现

安装类型

其他

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

No response

版本
sing-box v1.8.2
描述

在Linux服务器上用sing-box搭建此链路:ss[inbound] -> local dns -> socks[outbound]
链路中的inbound和outbound可以是任意协议,local的dns detour配置direct即可复现,其中dns缓存可能会混淆视听,建议关闭缓存测试。

初步判断问题出在此处:
image
image
linux版本的情况下,local dns把请求的ctx直接透传到了dns的detour(direct)里面了,在outbound direct中为了保存dail的真实ip和urltest情况时真实使用的outbound,选择了覆盖Outbound和Destination,因此导致请求的目标地址被覆盖了。(windows的local实现是调用系统接口无视了detour所以不会出现此问题)

重现方式

在Linux服务器上用sing-box搭建此链路:ss[inbound] -> local dns -> socks[outbound]
链路中的inbound和outbound可以是任意协议,local的dns detour配置direct即可复现,其中dns缓存可能会混淆视听,建议关闭缓存测试(windows local dns不会出现此问题)。

日志
+0800 2024-04-12 23:11:05 INFO [1238720400 0ms] inbound/http[4f2f3938-9bae-42d4-93c7-67ae99ca3d98_3121256]: inbound connection from 116.23.170.64:27451
+0800 2024-04-12 23:11:05 INFO [1238720400 12ms] inbound/http[4f2f3938-9bae-42d4-93c7-67ae99ca3d98_3121256]: [1fc022a794e3128642e730b09ba18608_1712901470] inbound connection to sso.geiwohuo.com:443
+0800 2024-04-12 23:11:05 INFO [1238720400 12ms] outbound/direct[direct]: outbound packet connection to 10.99.1.208:53
+0800 2024-04-12 23:11:05 INFO [1238720400 12ms] dns: lookup succeed for sso.geiwohuo.com: 47.106.166.73 47.106.181.133
+0800 2024-04-12 23:11:05 INFO [1238720400 12ms] outbound/socks[4f2f3938-9bae-42d4-93c7-67ae99ca3d98_3121256]: outbound connection to 47.106.166.73:53
+0800 2024-04-12 23:11:37 INFO [1238720400 31.68s] outbound/socks[4f2f3938-9bae-42d4-93c7-67ae99ca3d98_3121256]: outbound connection to 47.106.181.133:53
+0800 2024-04-12 23:12:09 ERROR [1238720400 1m3s] inbound/http[4f2f3938-9bae-42d4-93c7-67ae99ca3d98_3121256]: process connection from 116.23.170.64:27451: socks5: request rejected, code=5
支持我们
完整性要求
  • 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
  • 我保证提供了可以在本地重现该问题的服务器、客户端配置文件与流程,而不是一个脱敏的复杂客户端配置文件。
  • 我保证提供了可用于重现我报告的错误的最简配置,而不是依赖远程服务器、TUN、图形界面客户端或者其他闭源软件。
  • 我保证提供了完整的配置文件与日志,而不是出于对自身智力的自信而仅提供了部分认为有用的部分。
Dominant language
Go
Stars
38.2k
Forks
4.6k
Avg merge
19d 15h
Merged PRs (30d)
1

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.

More from SagerNet/sing-box

All issues in SagerNet/sing-box

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.