dns: Add neighbor-based hostname resolution to local server

This commit is contained in:
世界
2026-04-29 22:26:10 +08:00
parent 5386bbf63e
commit 594e6aaff6
16 changed files with 290 additions and 71 deletions
+19 -1
View File
@@ -2,6 +2,10 @@
icon: material/new-box
---
!!! quote "Changes in sing-box 1.14.0"
:material-plus: [neighbor_domain](#neighbor_domain)
!!! quote "Changes in sing-box 1.13.0"
:material-plus: [prefer_go](#prefer_go)
@@ -19,7 +23,8 @@ icon: material/new-box
{
"type": "local",
"tag": "",
"prefer_go": false
"prefer_go": false,
"neighbor_domain": []
// Dial Fields
}
@@ -56,6 +61,19 @@ On devices running Android versions lower than 10, this interface can only resol
2. On macOS, `local` will try DHCP first in Network Extension, since DHCP respects DIal Fields,
it will not be disabled by `prefer_go`.
#### neighbor_domain
!!! question "Since sing-box 1.14.0"
A list of domain suffixes for which A/AAAA queries are answered from the
[neighbor resolver](/configuration/shared/neighbor/) instead of the upstream.
Each entry must start with `.`. Only queries whose host part (the portion
before the suffix) contains no dots are matched; `.` matches any
single-label name such as `nas`.
Example: `[".", ".lan"]`.
### Dial Fields
See [Dial Fields](/configuration/shared/dial/) for details.
+16
View File
@@ -2,6 +2,10 @@
icon: material/new-box
---
!!! quote "sing-box 1.14.0 中的更改"
:material-plus: [neighbor_domain](#neighbor_domain)
!!! quote "sing-box 1.13.0 中的更改"
:material-plus: [prefer_go](#prefer_go)
@@ -20,6 +24,7 @@ icon: material/new-box
"type": "local",
"tag": "",
"prefer_go": false,
"neighbor_domain": [],
// 拨号字段
}
@@ -56,6 +61,17 @@ icon: material/new-box
2. 在 macOS 上,`local` 会在 Network Extension 中首先尝试 DHCP,由于 DHCP 遵循拨号字段,
它不会被 `prefer_go` 禁用。
#### neighbor_domain
!!! question "自 sing-box 1.14.0 起"
用于从[邻居解析器](/zh/configuration/shared/neighbor/)而非上游回答 A/AAAA 查询的域后缀列表。
每一项必须以 `.` 开头。仅匹配后缀之前的主机名部分不包含点的查询;
`.` 匹配任意单标签名称,例如 `nas`
示例:`[".", ".lan"]`
### 拨号字段
参阅 [拨号字段](/zh/configuration/shared/dial/) 了解详情。
+3 -1
View File
@@ -8,7 +8,9 @@ Match LAN devices by MAC address and hostname using
[`source_mac_address`](/configuration/route/rule/#source_mac_address) and
[`source_hostname`](/configuration/route/rule/#source_hostname) rule items.
Neighbor resolution is automatically enabled when these rule items exist.
Neighbor resolution is automatically enabled when these rule items exist
or when a [local DNS server](/configuration/dns/server/local/) sets
[neighbor_domain](/configuration/dns/server/local/#neighbor_domain).
Use [`route.find_neighbor`](/configuration/route/#find_neighbor) to force enable it for logging without rules.
## Linux
+1 -1
View File
@@ -8,7 +8,7 @@ icon: material/lan
[`source_mac_address`](/configuration/route/rule/#source_mac_address) 和
[`source_hostname`](/configuration/route/rule/#source_hostname) 规则项匹配局域网设备的 MAC 地址和主机名。
当这些规则项存在时,邻居解析自动启用。
当这些规则项存在,或 [local DNS 服务器](/zh/configuration/dns/server/local/) 设置了 [neighbor_domain](/zh/configuration/dns/server/local/#neighbor_domain) 时,邻居解析自动启用。
使用 [`route.find_neighbor`](/configuration/route/#find_neighbor) 可在没有规则时强制启用以输出日志。
## Linux