Files
sing-box-extended-mirror/docs/configuration/dns/index.md
T

146 lines
3.2 KiB
Markdown
Raw Normal View History

2024-11-14 12:42:42 +08:00
---
2025-05-29 12:13:07 +08:00
icon: material/alert-decagram
2024-11-14 12:42:42 +08:00
---
2026-04-11 12:10:52 +08:00
!!! quote "Changes in sing-box 1.14.0"
:material-delete-clock: [independent_cache](#independent_cache)
2026-04-28 14:29:52 +08:00
:material-plus: [optimistic](#optimistic)
:material-plus: [timeout](#timeout)
2026-04-11 12:10:52 +08:00
2025-05-29 12:13:07 +08:00
!!! quote "Changes in sing-box 1.12.0"
:material-decagram: [servers](#servers)
2024-11-14 12:42:42 +08:00
!!! quote "Changes in sing-box 1.11.0"
:material-plus: [cache_capacity](#cache_capacity)
2022-08-25 21:08:29 +08:00
# DNS
2022-07-08 17:01:38 +08:00
### Structure
```json
{
"dns": {
"servers": [],
"rules": [],
"final": "",
"strategy": "",
2022-07-08 17:01:38 +08:00
"disable_cache": false,
2023-03-23 19:08:48 +08:00
"disable_expire": false,
2023-04-26 04:53:25 +08:00
"independent_cache": false,
2024-11-14 12:42:42 +08:00
"cache_capacity": 0,
2026-04-11 12:10:52 +08:00
"optimistic": false, // or {}
2026-04-28 14:29:52 +08:00
"timeout": "",
2023-03-25 12:03:23 +08:00
"reverse_mapping": false,
2024-02-09 18:37:25 +08:00
"client_subnet": "",
2023-03-25 12:03:23 +08:00
"fakeip": {}
2022-07-08 17:01:38 +08:00
}
}
```
### Fields
2024-02-03 17:45:27 +08:00
| Key | Format |
|----------|---------------------------------|
2023-12-14 22:23:52 +08:00
| `server` | List of [DNS Server](./server/) |
| `rules` | List of [DNS Rule](./rule/) |
| `fakeip` | :material-note-remove: [FakeIP](./fakeip/) |
2022-07-08 17:01:38 +08:00
#### final
Default dns server tag.
The first server will be used if empty.
2022-07-08 17:01:38 +08:00
#### strategy
Default domain strategy for resolving the domain names.
One of `prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`.
#### disable_cache
Disable dns cache.
2026-04-11 12:10:52 +08:00
Conflict with `optimistic`.
2022-07-08 17:01:38 +08:00
#### disable_expire
2023-03-23 19:08:48 +08:00
Disable dns cache expire.
2026-04-11 12:10:52 +08:00
Conflict with `optimistic`.
2023-04-26 04:53:25 +08:00
#### independent_cache
2026-04-11 12:10:52 +08:00
!!! failure "Deprecated in sing-box 1.14.0"
`independent_cache` is deprecated and will be removed in sing-box 1.14.0, check [Migration](/migration/#migrate-independent-dns-cache).
2023-04-26 04:53:25 +08:00
Make each DNS server's cache independent for special purposes. If enabled, will slightly degrade performance.
2024-11-14 12:42:42 +08:00
#### cache_capacity
2024-11-14 18:31:37 +08:00
!!! question "Since sing-box 1.11.0"
2024-11-14 12:42:42 +08:00
LRU cache capacity.
Value less than 1024 will be ignored.
2026-04-11 12:10:52 +08:00
#### optimistic
!!! question "Since sing-box 1.14.0"
Enable optimistic DNS caching. When a cached DNS entry has expired but is still within the timeout window,
the stale response is returned immediately while a background refresh is triggered.
Conflict with `disable_cache` and `disable_expire`.
Accepts a boolean or an object. When set to `true`, the default timeout of `3d` is used.
```json
{
"enabled": true,
"timeout": "3d"
}
```
##### enabled
Enable optimistic DNS caching.
##### timeout
The maximum time an expired cache entry can be served optimistically.
`3d` is used by default.
2026-04-28 14:29:52 +08:00
#### timeout
!!! question "Since sing-box 1.14.0"
Default timeout for each DNS query.
`10s` is used by default.
Can be overridden by `rules.[].timeout` (DNS rule action) or `domain_resolver.timeout`.
2023-03-23 19:08:48 +08:00
#### reverse_mapping
Stores a reverse mapping of IP addresses after responding to a DNS query in order to provide domain names when routing.
2023-03-25 12:03:23 +08:00
Since this process relies on the act of resolving domain names by an application before making a request, it can be
problematic in environments such as macOS, where DNS is proxied and cached by the system.
2024-02-09 18:37:25 +08:00
#### client_subnet
!!! question "Since sing-box 1.9.0"
Append a `edns0-subnet` OPT extra record with the specified IP prefix to every query by default.
If value is an IP address instead of prefix, `/32` or `/128` will be appended automatically.
2023-03-25 12:03:23 +08:00
Can be overridden by `servers.[].client_subnet` or `rules.[].client_subnet`.