diff --git a/docs/config/outbounds/wireguard.md b/docs/config/outbounds/wireguard.md
index af74c3d0..2bf5d5f0 100644
--- a/docs/config/outbounds/wireguard.md
+++ b/docs/config/outbounds/wireguard.md
@@ -16,7 +16,7 @@
{
// ...
"protocol": "wireguard",
- // [!code focus:18]
+ // [!code focus:25]
"settings": {
"secretKey": "CLIENT_PRIVATE_KEY",
"address": [
@@ -27,13 +27,20 @@
"peers": [
{
"endpoint": "SERVER_ADDR",
- "publicKey": "SERVER_PUBLIC_KEY"
+ "publicKey": "SERVER_PUBLIC_KEY",
+ "allowedIPs": ["0.0.0.0/0", "::/0"]
+ // ...
}
],
"noKernelTun": false,
"mtu": 1420,
"reserved": [0, 0, 0],
- "domainStrategy": "ForceIP"
+ "remoteDNS": [
+ "1.1.1.1",
+ "1.0.0.1",
+ "2606:4700:4700::1111",
+ "2606:4700:4700::1001"
+ ]
}
}
]
@@ -111,14 +118,23 @@ Xray 会使用内层目标地址对各 peer 的 `allowedIPs` 进行前缀匹配
以 Xray 作为 WireGuard 服务器为例,应在 `inbounds[].settings.peers[].allowedIPs` 中列出这些地址。
:::
-> `domainStrategy`: "ForceIPv6v4" | "ForceIPv6" | "ForceIPv4v6" | "ForceIPv4" | "ForceIP"
+> `remoteDNS`: \[ string \]
-当 WireGuard 服务器地址为域名、被代理流量目标地址是域名时,控制它们的域名解析策略。
+用于解析被代理目标的域名。列表项必须为 IP。默认值为 `["1.1.1.1", "1.0.0.1", "2606:4700:4700::1111", "2606:4700:4700::1001"]`。
-不像绝大多数代理协议,WireGuard 不允许传递域名作为目标,所以如果传入目标为域名,需要先解析为 IP 再传送。此处字段含义与 [sockopt.domainStrategy](../transports/sockopt.md#sockoptobject) 中对应的 `Force` 策略相同,默认值为 `ForceIP`。
+DNS 查询经 WireGuard 隧道发送;所有服务器 IP 均须包含在某个 peer 的 `allowedIPs` 中并能通过隧道访问。
-`sockopt.domainStrategy` 包含诸如 `UseIP` 的选项,在这里不提供,因为 WireGuard 必须获取一个可用的 IP,不能执行 `UseIP` 解析失败后回落为域名的行为。
-注意:作用于被代理流量时,此选项还受 `address` 选项的约束,比如你设置了 ForceIPv6v4 但是 address 中没有设置 IPv6 地址,尽管目标域名有 AAAA 记录也不会解析。
+::: details `remoteDNS` 与 `targetStrategy`
+不同于其他出站,WireGuard 隧道内的目标地址必须为 IP。当被代理目标为域名时,出站的 [`targetStrategy`](../outbound.md#outboundobject) 决定使用哪套 DNS 进行解析:
+
+- `AsIs`:使用 `remoteDNS`。
+- `UseIP*`:优先使用 Xray 内置 DNS,解析失败时回退到 `remoteDNS`。
+- `ForceIP*`:使用 Xray 内置 DNS,解析失败时直接失败。
+
+`UseIP*` 或 `ForceIP*` 的解析结果中,至少要有一个 IP 与 `address` 中的地址属于同一地址族,否则无法连接。地址族不匹配不视为解析失败,也不会触发任何回退。
+
+如何取舍?`remoteDNS` 开箱即用,查询经 WireGuard 隧道发出,通常可获得与隧道出口匹配的 CDN 解析结果;若要让 [Xray 内置 DNS](../dns.md) 达到同样效果,通常还需配置相应的 DNS 服务器和路由规则。但若内置 DNS 事先解析过目标域名(例如使用 TUN/TProxy 的 RealIP 方案,或开启嗅探且 `routing.domainStrategy` 非 `AsIs`),建议使用 Xray 内置 DNS,以避免二次解析增加 RTT。
+:::
### PeersObject
@@ -153,6 +169,6 @@ IP: 端口 格式,例如 `162.159.192.1:2408` 或 `[2606:4700:d0::a29f:c001]:2
客户端向该服务器发送持久保活包的间隔,单位为秒,用于在空闲时维持可能存在的 NAT 映射或防火墙状态。仅特殊场景需要开启,且仅客户端开启即可;默认值为 `0`,表示不发送。
-> `allowedIPs`: string array
+> `allowedIPs`: \[ string \]
指定由该服务器转发的目标 IP 网段,每项使用 CIDR 表示。仅配置一个服务器时可以省略,因为默认值为 `["0.0.0.0/0", "::/0"]`,即所有 IPv4 和 IPv6 目标流量均由该服务器转发。配置多个服务器时,需为每个服务器显式设置 `allowedIPs`,将不同的目标网段分配给相应服务器;Xray 会根据目标 IP 的前缀匹配结果选择服务器。
diff --git a/docs/en/config/outbounds/wireguard.md b/docs/en/config/outbounds/wireguard.md
index 282b5f04..5a869488 100644
--- a/docs/en/config/outbounds/wireguard.md
+++ b/docs/en/config/outbounds/wireguard.md
@@ -16,7 +16,7 @@ User-space WireGuard protocol implementation for establishing a WireGuard tunnel
{
// ...
"protocol": "wireguard",
- // [!code focus:18]
+ // [!code focus:25]
"settings": {
"secretKey": "CLIENT_PRIVATE_KEY",
"address": [
@@ -27,13 +27,20 @@ User-space WireGuard protocol implementation for establishing a WireGuard tunnel
"peers": [
{
"endpoint": "SERVER_ADDR",
- "publicKey": "SERVER_PUBLIC_KEY"
+ "publicKey": "SERVER_PUBLIC_KEY",
+ "allowedIPs": ["0.0.0.0/0", "::/0"]
+ // ...
}
],
"noKernelTun": false,
"mtu": 1420,
"reserved": [0, 0, 0],
- "domainStrategy": "ForceIP"
+ "remoteDNS": [
+ "1.1.1.1",
+ "1.0.0.1",
+ "2606:4700:4700::1111",
+ "2606:4700:4700::1001"
+ ]
}
}
]
@@ -111,14 +118,23 @@ Each WireGuard server must allow all addresses in `address` that belong to the s
When using Xray as the WireGuard server, list these addresses in `inbounds[].settings.peers[].allowedIPs`.
:::
-> `domainStrategy`: "ForceIPv6v4" | "ForceIPv6" | "ForceIPv4v6" | "ForceIPv4" | "ForceIP"
+> `remoteDNS`: \[ string \]
-Controls the domain resolution strategy when the WireGuard server address or the target address of the proxied traffic is a domain name.
+Used to resolve proxied target domain names. Each item must be an IP address. The default is `["1.1.1.1", "1.0.0.1", "2606:4700:4700::1111", "2606:4700:4700::1001"]`.
-Unlike most proxy protocols, WireGuard does not allow domain names to be passed as targets. If the incoming target is a domain name, it must therefore be resolved to an IP address before transmission. The meanings of this field match the corresponding `Force` strategies in [sockopt.domainStrategy](../transports/sockopt.md#sockoptobject). The default is `ForceIP`.
+DNS queries are sent through the WireGuard tunnel; every server IP must be included in a peer's `allowedIPs` and reachable through the tunnel.
-`sockopt.domainStrategy` includes options such as `UseIP`, which are not available here because WireGuard must obtain a usable IP address and cannot fall back to a domain name when `UseIP` resolution fails.
-Note: When applied to proxied traffic, this option is also constrained by `address`. For example, if you set `ForceIPv6v4` but do not configure an IPv6 address in `address`, AAAA records will not be resolved even if the target domain has them.
+::: details `remoteDNS` and `targetStrategy`
+Unlike other outbounds, targets inside a WireGuard tunnel must be IP addresses. When the proxied target is a domain name, the outbound's [`targetStrategy`](../outbound.md#outboundobject) determines which DNS is used to resolve it:
+
+- `AsIs`: uses `remoteDNS`.
+- `UseIP*`: tries Xray's built-in DNS first and falls back to `remoteDNS` if resolution fails.
+- `ForceIP*`: uses Xray's built-in DNS and fails immediately if resolution fails.
+
+The results returned by `UseIP*` or `ForceIP*` must contain at least one IP whose address family matches an address in `address`; otherwise, the connection fails. An address-family mismatch is not treated as a resolution failure and does not trigger any fallback.
+
+Which should you choose? `remoteDNS` works out of the box and sends queries through the WireGuard tunnel, usually producing CDN resolution results suited to the tunnel's exit location. Achieving the same result with [Xray's built-in DNS](../dns.md) usually requires additional DNS server and routing rules. However, if the built-in DNS resolved the target domain earlier—for example, when using a RealIP setup with TUN/TProxy, or when sniffing is enabled and `routing.domainStrategy` is not `AsIs`—using Xray's built-in DNS is recommended to avoid the additional RTT of a second resolution.
+:::
### PeersObject
@@ -153,6 +169,6 @@ Optional additional symmetric encryption key. It must match the server configura
Interval, in seconds, at which the client sends persistent keepalive packets to this server. This maintains any NAT mappings or firewall state during idle periods. Enable it only in special situations and only on the client. The default is `0`, which disables keepalive packets.
-> `allowedIPs`: string array
+> `allowedIPs`: \[ string \]
Specifies the destination IP networks forwarded by this server, with each item expressed in CIDR notation. This field can be omitted when only one server is configured because the default is `["0.0.0.0/0", "::/0"]`, meaning that the server forwards all IPv4 and IPv6 destination traffic. When multiple servers are configured, explicitly set `allowedIPs` for each server to assign different destination networks to the appropriate server; Xray selects the server by prefix-matching the destination IP address.
diff --git a/docs/ru/config/outbounds/wireguard.md b/docs/ru/config/outbounds/wireguard.md
index 1a426f0c..84c2c3a1 100644
--- a/docs/ru/config/outbounds/wireguard.md
+++ b/docs/ru/config/outbounds/wireguard.md
@@ -16,7 +16,7 @@
{
// ...
"protocol": "wireguard",
- // [!code focus:18]
+ // [!code focus:25]
"settings": {
"secretKey": "CLIENT_PRIVATE_KEY",
"address": [
@@ -27,13 +27,20 @@
"peers": [
{
"endpoint": "SERVER_ADDR",
- "publicKey": "SERVER_PUBLIC_KEY"
+ "publicKey": "SERVER_PUBLIC_KEY",
+ "allowedIPs": ["0.0.0.0/0", "::/0"]
+ // ...
}
],
"noKernelTun": false,
"mtu": 1420,
"reserved": [0, 0, 0],
- "domainStrategy": "ForceIP"
+ "remoteDNS": [
+ "1.1.1.1",
+ "1.0.0.1",
+ "2606:4700:4700::1111",
+ "2606:4700:4700::1001"
+ ]
}
}
]
@@ -111,14 +118,23 @@ Xray сопоставляет внутренний адрес назначени
Если в качестве сервера WireGuard используется Xray, перечислите эти адреса в `inbounds[].settings.peers[].allowedIPs`.
:::
-> `domainStrategy`: "ForceIPv6v4" | "ForceIPv6" | "ForceIPv4v6" | "ForceIPv4" | "ForceIP"
+> `remoteDNS`: \[ string \]
-Управляет стратегией разрешения доменных имён, когда адрес сервера WireGuard или адрес назначения проксируемого трафика является доменным именем.
+Используется для разрешения целевых доменных имён проксируемого трафика. Каждый элемент должен быть IP-адресом. Значение по умолчанию — `["1.1.1.1", "1.0.0.1", "2606:4700:4700::1111", "2606:4700:4700::1001"]`.
-В отличие от большинства прокси-протоколов, WireGuard не позволяет передавать доменные имена в качестве назначения. Поэтому, если входящее назначение задано доменным именем, перед отправкой его необходимо разрешить в IP-адрес. Значения этого поля соответствуют стратегиям `Force` в [sockopt.domainStrategy](../transports/sockopt.md#sockoptobject). Значение по умолчанию — `ForceIP`.
+DNS-запросы отправляются через туннель WireGuard; IP-адрес каждого сервера должен входить в `allowedIPs` одного из пиров и быть доступен через туннель.
-В `sockopt.domainStrategy` есть такие параметры, как `UseIP`, но здесь они недоступны: WireGuard должен получить пригодный IP-адрес и не может вернуться к доменному имени при ошибке разрешения `UseIP`.
-Примечание: при применении к проксируемому трафику этот параметр также ограничен настройкой `address`. Например, если задано `ForceIPv6v4`, но в `address` нет адреса IPv6, записи AAAA не будут разрешаться, даже если они существуют для домена назначения.
+::: details `remoteDNS` и `targetStrategy`
+В отличие от других исходящих подключений, целью внутри туннеля WireGuard должен быть IP-адрес. Если целью проксируемого запроса является доменное имя, параметр [`targetStrategy`](../outbound.md#outboundobject) исходящего подключения определяет, какой DNS используется для его разрешения:
+
+- `AsIs`: используется `remoteDNS`.
+- `UseIP*`: сначала используется встроенный DNS Xray, а при ошибке разрешения выполняется переход на `remoteDNS`.
+- `ForceIP*`: используется встроенный DNS Xray; ошибка разрешения сразу приводит к ошибке подключения.
+
+Результаты `UseIP*` или `ForceIP*` должны содержать хотя бы один IP-адрес того же семейства, что и один из адресов в `address`; иначе соединение завершится ошибкой. Несовпадение семейств адресов не считается ошибкой разрешения и не запускает никакой переход на резервный вариант.
+
+Что выбрать? `remoteDNS` работает сразу, без дополнительной настройки, и отправляет запросы через туннель WireGuard, что обычно позволяет получить результаты CDN, соответствующие расположению выхода из туннеля. Для достижения того же результата с помощью [встроенного DNS Xray](../dns.md) обычно требуется дополнительно настроить DNS-серверы и правила маршрутизации. Однако если встроенный DNS ранее уже разрешил целевое доменное имя — например, при использовании схемы RealIP с TUN/TProxy либо при включённом сниффинге и значении `routing.domainStrategy`, отличном от `AsIs`, — рекомендуется использовать встроенный DNS Xray, чтобы избежать дополнительной задержки RTT из-за повторного разрешения.
+:::
### PeersObject
@@ -153,6 +169,6 @@ Xray сопоставляет внутренний адрес назначени
Интервал отправки клиентом этому серверу пакетов persistent keepalive, в секундах. Они поддерживают возможные сопоставления NAT или состояние межсетевого экрана в периоды простоя. Включайте этот параметр только при необходимости и только на стороне клиента. Значение по умолчанию — `0`, то есть пакеты не отправляются.
-> `allowedIPs`: string array
+> `allowedIPs`: \[ string \]
Задаёт IP-сети назначения, пересылаемые через этот сервер. Каждый элемент указывается в формате CIDR. При наличии только одного сервера поле можно опустить: значение по умолчанию — `["0.0.0.0/0", "::/0"]`, то есть через сервер направляется весь трафик к адресам IPv4 и IPv6. Если настроено несколько серверов, необходимо явно задать `allowedIPs` для каждого из них и распределить сети назначения между соответствующими серверами; Xray выбирает сервер путём сопоставления префикса IP-адреса назначения.