dns: Add mDNS server

This commit is contained in:
世界 2026-04-30 19:42:30 +08:00
parent fdec2fe051
commit 98b21227fa
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
18 changed files with 662 additions and 176 deletions

View file

@ -507,11 +507,12 @@ Match source device hostname from DHCP leases.
Match specified DNS servers' preferred domains.
| Type | Match |
|-------------|-----------------------------------------------------|
| `hosts` | Match predefined entries and entries in hosts files |
| `local` | Match hosts entries and neighbor-resolved hosts |
| `tailscale` | Match MagicDNS hosts and DNS route suffixes |
| Type | Match |
|-------------|------------------------------------------------------------------------------|
| `hosts` | Match predefined entries and entries in hosts files |
| `local` | Match hosts entries, neighbor-resolved hosts, and mDNS local domains |
| `mdns` | Match mDNS local domains (`*.local.` and IPv4/IPv6 link-local reverse zones) |
| `tailscale` | Match MagicDNS hosts and DNS route suffixes |
#### wifi_ssid

View file

@ -499,11 +499,12 @@ Available values: `wifi`, `cellular`, `ethernet` and `other`.
匹配指定 DNS 服务器的首选域名。
| 类型 | 匹配 |
|-------------|--------------------------|
| `hosts` | 匹配预定义条目和 hosts 文件中的条目 |
| `local` | 匹配 hosts 中的条目和邻居解析得到的主机名 |
| `tailscale` | 匹配 MagicDNS 主机和 DNS 路由后缀 |
| 类型 | 匹配 |
|-------------|-------------------------------------------------------------|
| `hosts` | 匹配预定义条目和 hosts 文件中的条目 |
| `local` | 匹配 hosts 中的条目、邻居解析得到的主机名以及 mDNS 本地域名 |
| `mdns` | 匹配 mDNS 本地域名(`*.local.` 以及 IPv4/IPv6 链路本地反向区域) |
| `tailscale` | 匹配 MagicDNS 主机和 DNS 路由后缀 |
#### wifi_ssid

View file

@ -2,6 +2,10 @@
icon: material/alert-decagram
---
!!! quote "Changes in sing-box 1.14.0"
:material-plus: [mdns](./mdns/)
!!! quote "Changes in sing-box 1.12.0"
:material-plus: [type](#type)
@ -39,6 +43,7 @@ The type of the DNS server.
| `https` | [HTTPS](./https/) |
| `h3` | [HTTP/3](./http3/) |
| `dhcp` | [DHCP](./dhcp/) |
| `mdns` | [mDNS](./mdns/) |
| `fakeip` | [Fake IP](./fakeip/) |
| `tailscale` | [Tailscale](./tailscale/) |
| `resolved` | [Resolved](./resolved/) |

View file

@ -2,6 +2,10 @@
icon: material/alert-decagram
---
!!! quote "sing-box 1.14.0 中的更改"
:material-plus: [mdns](./mdns/)
!!! quote "sing-box 1.12.0 中的更改"
:material-plus: [type](#type)
@ -39,6 +43,7 @@ DNS 服务器的类型。
| `https` | [HTTPS](./https/) |
| `h3` | [HTTP/3](./http3/) |
| `dhcp` | [DHCP](./dhcp/) |
| `mdns` | [mDNS](./mdns/) |
| `fakeip` | [Fake IP](./fakeip/) |
| `tailscale` | [Tailscale](./tailscale/) |
| `resolved` | [Resolved](./resolved/) |

View file

@ -0,0 +1,42 @@
---
icon: material/new-box
---
!!! question "Since sing-box 1.14.0"
# mDNS
### Structure
```json
{
"dns": {
"servers": [
{
"type": "mdns",
"tag": "",
"interface": [],
// Dial Fields
}
]
}
}
```
!!! info ""
You usually do not need an explicit `mdns` server in addition to a [Local](./local/) server: the local server already routes queries for `*.local.` and IPv4/IPv6 link-local reverse zones via mDNS on non-Apple platforms and via the system resolver on Apple platforms. Add an explicit `mdns` server only when you want to reference it from [`preferred_by`](../rule/#preferred_by) or use it standalone.
### Fields
#### interface
List of network interface names to send mDNS queries on.
When empty, all interfaces that are up, multicast-capable, and non-loopback are used.
### Dial Fields
See [Dial Fields](/configuration/shared/dial/) for details.

View file

@ -0,0 +1,42 @@
---
icon: material/new-box
---
!!! question "自 sing-box 1.14.0 起"
# mDNS
### 结构
```json
{
"dns": {
"servers": [
{
"type": "mdns",
"tag": "",
"interface": [],
// 拨号字段
}
]
}
}
```
!!! info ""
通常不需要在 [Local](./local/) 服务器之外再添加显式的 `mdns` 服务器:本地服务器已经会在非 Apple 平台通过 mDNS、在 Apple 平台通过系统解析器来回答 `*.local.` 与 IPv4/IPv6 链路本地反向区域的查询。仅当需要从 [`preferred_by`](../rule/#preferred_by) 引用,或独立使用时,才需要显式添加 `mdns` 服务器。
### 字段
#### interface
用于发送 mDNS 查询的网络接口名称列表。
留空时,将使用所有处于 up 状态、支持多播且非环回的接口。
### 拨号字段
参阅 [拨号字段](/zh/configuration/shared/dial/) 了解详情。