Skip to content

Commit

Permalink
documentation: Refactor DNS
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Jan 29, 2025
1 parent c230ffd commit 413d223
Show file tree
Hide file tree
Showing 24 changed files with 1,680 additions and 8 deletions.
8 changes: 8 additions & 0 deletions docs/configuration/dns/fakeip.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
icon: material/delete-clock
---

!!! failure "Deprecated in sing-box 1.12.0"

Legacy fake-ip configuration is deprecated and will be removed in sing-box 1.14.0, check [Migration](/migration/#migrate-to-new-dns-servers).

### Structure

```json
Expand Down
8 changes: 8 additions & 0 deletions docs/configuration/dns/fakeip.zh.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
icon: material/delete-clock
---

!!! failure "已在 sing-box 1.12.0 废弃"

旧的 fake-ip 配置已废弃且将在 sing-box 1.14.0 中被移除,参阅 [迁移指南](/migration/#migrate-to-new-dns-servers)。

### 结构

```json
Expand Down
2 changes: 0 additions & 2 deletions docs/configuration/dns/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ Default domain strategy for resolving the domain names.

One of `prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`.

Take no effect if `server.strategy` is set.

#### disable_cache

Disable dns cache.
Expand Down
2 changes: 0 additions & 2 deletions docs/configuration/dns/index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ icon: material/new-box

可选值: `prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`

如果设置了 `server.strategy`,则不生效。

#### disable_cache

禁用 DNS 缓存。
Expand Down
11 changes: 11 additions & 0 deletions docs/configuration/dns/rule_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
icon: material/new-box
---

!!! quote "Changes in sing-box 1.12.0"

:material-plus: [strategy](#strategy)

!!! question "Since sing-box 1.11.0"

### route
Expand All @@ -10,6 +14,7 @@ icon: material/new-box
{
"action": "route", // default
"server": "",
"strategy": "",
"disable_cache": false,
"rewrite_ttl": 0,
"client_subnet": null
Expand All @@ -24,6 +29,12 @@ icon: material/new-box

Tag of target server.

#### strategy

Set domain strategy for this query.

One of `prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`.

#### disable_cache

Disable cache and save cache in this query.
Expand Down
14 changes: 12 additions & 2 deletions docs/configuration/dns/rule_action.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
icon: material/new-box
---

!!! quote "sing-box 1.12.0 中的更改"

:material-plus: [strategy](#strategy)

!!! question "自 sing-box 1.11.0 起"

### route
Expand All @@ -10,8 +14,8 @@ icon: material/new-box
{
"action": "route", // 默认
"server": "",
// 兼容性

"strategy": "",
"disable_cache": false,
"rewrite_ttl": 0,
"client_subnet": null
Expand All @@ -26,6 +30,12 @@ icon: material/new-box

目标 DNS 服务器的标签。

#### strategy

为此查询设置域名策略。

可选项:`prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`

#### disable_cache

在此查询中禁用缓存。
Expand Down
38 changes: 38 additions & 0 deletions docs/configuration/dns/server/dhcp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
icon: material/new-box
---

!!! question "Since sing-box 1.12.0"

# DHCP

### Structure

```json
{
"dns": {
"servers": [
{
"type": "dhcp",
"tag": "",

"interface": "",

// Dial Fields
}
]
}
}
```

### Fields

#### interface

Interface name to listen on.

Tge default interface will be used by default.

### Dial Fields

See [Dial Fields](/configuration/shared/dial/) for details.
33 changes: 33 additions & 0 deletions docs/configuration/dns/server/fakeip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
icon: material/new-box
---

!!! question "Since sing-box 1.12.0"

# Fake IP

### Structure

```json
{
"dns": {
"servers": {
"type": "fakeip",
"tag": "",

"inet4_range": "198.18.0.0/15",
"inet6_range": "fc00::/18"
}
}
}
```

### Fields

#### inet4_range

IPv4 address range for FakeIP.

#### inet6_address

IPv6 address range for FakeIP.
69 changes: 69 additions & 0 deletions docs/configuration/dns/server/http3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
icon: material/new-box
---

!!! question "Since sing-box 1.12.0"

# DNS over HTTP3 (DoH3)

### Structure

```json
{
"dns": {
"servers": {
"type": "h3",
"tag": "",

"server": "",
"server_port": 443,

"path": "",
"headers": {},

"tls": {},

// Dial Fields
}
}
}
```

!!! info "Difference from legacy H3 server"

* The old server uses default outbound by default unless detour is specified; the new one uses dialer just like outbound, which is equivalent to using an empty direct outbound by default.
* The old server uses `address_resolver` and `address_strategy` to resolve the domain name in the server; the new one uses `domain_resolver` and `domain_strategy` in [Dial Fields](/configuration/shared/dial/) instead.

### Fields

#### server

==Required==

The address of the DNS server.

If domain name is used, `domain_resolver` must also be set to resolve IP address.

#### server_port

The port of the DNS server.

`853` will be used by default.

#### path

The path of the DNS server.

`/dns-query` will be used by default.

#### headers

Additional headers to be sent to the DNS server.

#### tls

TLS configuration, see [TLS](/configuration/shared/tls/#outbound).

### Dial Fields

See [Dial Fields](/configuration/shared/dial/) for details.
69 changes: 69 additions & 0 deletions docs/configuration/dns/server/https.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
icon: material/new-box
---

!!! question "Since sing-box 1.12.0"

# DNS over HTTPS (DoH)

### Structure

```json
{
"dns": {
"servers": {
"type": "https",
"tag": "",

"server": "",
"server_port": 443,

"path": "",
"headers": {},

"tls": {},

// Dial Fields
}
}
}
```

!!! info "Difference from legacy HTTPS server"

* The old server uses default outbound by default unless detour is specified; the new one uses dialer just like outbound, which is equivalent to using an empty direct outbound by default.
* The old server uses `address_resolver` and `address_strategy` to resolve the domain name in the server; the new one uses `domain_resolver` and `domain_strategy` in [Dial Fields](/configuration/shared/dial/) instead.

### Fields

#### server

==Required==

The address of the DNS server.

If domain name is used, `domain_resolver` must also be set to resolve IP address.

#### server_port

The port of the DNS server.

`853` will be used by default.

#### path

The path of the DNS server.

`/dns-query` will be used by default.

#### headers

Additional headers to be sent to the DNS server.

#### tls

TLS configuration, see [TLS](/configuration/shared/tls/#outbound).

### Dial Fields

See [Dial Fields](/configuration/shared/dial/) for details.
46 changes: 46 additions & 0 deletions docs/configuration/dns/server/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
icon: material/alert-decagram
---

!!! quote "Changes in sing-box 1.12.0"

:material-plus: [type](#type)

# DNS Server

### Structure

```json
{
"dns": {
"servers": [
{
"type": "",
"tag": ""
}
]
}
}
```

#### type

The type of the DNS server.

| Type | Format |
|-----------------|-----------------------------------------------------|
| empty (default) | [Legacy](/configuration/dns/server/legacy/) |
| `tcp` | [TCP](/configuration/dns/server/tcp/) |
| `udp` | [UDP](/configuration/dns/server/udp/) |
| `tls` | [TLS](/configuration/dns/server/tls/) |
| `https` | [HTTPS](/configuration/dns/server/https/) |
| `quic` | [QUIC](/configuration/dns/server/quic/) |
| `h3` | [HTTP/3](/configuration/dns/server/http3/) |
| `predefined` | [Predefined](/configuration/dns/server/predefined/) |
| `dhcp` | [DHCP](/configuration/dns/server/dhcp/) |
| `fakeip` | [Fake IP](/configuration/dns/server/fakeip/) |


#### tag

The tag of the DNS server.
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
icon: material/delete-clock
---

!!! failure "Deprecated in sing-box 1.12.0"

Legacy DNS servers is deprecated and will be removed in sing-box 1.14.0, check [Migration](/migration/#migrate-to-new-dns-servers).

!!! quote "Changes in sing-box 1.9.0"

:material-plus: [client_subnet](#client_subnet)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
icon: material/delete-clock
---

!!! failure "Deprecated in sing-box 1.12.0"

旧的 DNS 服务器配置已废弃且将在 sing-box 1.14.0 中被移除,参阅 [迁移指南](/migration/#migrate-to-new-dns-servers)。

!!! quote "sing-box 1.9.0 中的更改"

:material-plus: [client_subnet](#client_subnet)
Expand Down
Loading

0 comments on commit 413d223

Please sign in to comment.