FakeDNS: Make JSON examples more user-friendly with parent context and focused snippets

This commit is contained in:
Meow
2026-05-07 19:58:31 +08:00
parent 90f358c032
commit e9e62ade55
3 changed files with 270 additions and 195 deletions
+90 -65
View File
@@ -12,24 +12,28 @@ FakeDNS 有可能会污染本地 DNS,导致 Xray 关闭后“无法访问网
```json
{
"ipPool": "198.18.0.0/16",
"poolSize": 65535
"fakedns": {
"ipPool": "198.18.0.0/16",
"poolSize": 65535
}
}
```
`FakeDnsObject` 亦可配置为一个包含多个 FakeIP Pool 的数组。当收到 DNS 查询请求时,FakeDNS 会返回一组同时由多个 FakeIP Pool 得到的一组 FakeIP。
```json
[
{
"ipPool": "198.18.0.0/15",
"poolSize": 65535
},
{
"ipPool": "fc00::/18",
"poolSize": 65535
}
]
{
"fakedns": [
{
"ipPool": "198.18.0.0/15",
"poolSize": 65535
},
{
"ipPool": "fc00::/18",
"poolSize": 65535
}
]
}
```
> `ipPool`: CIDR
@@ -50,24 +54,28 @@ FakeDNS 将使用此选项指定的 IP 块分配地址。
`queryStrategy` 为 `UseIP` 时,初始化的 FakeIP Pool 相当于
```json
[
{
"ipPool": "198.18.0.0/15",
"poolSize": 32768
},
{
"ipPool": "fc00::/18",
"poolSize": 32768
}
]
{
"fakedns": [
{
"ipPool": "198.18.0.0/15",
"poolSize": 32768
},
{
"ipPool": "fc00::/18",
"poolSize": 32768
}
]
}
```
`queryStrategy` 为 `UseIPv4` 时,初始化的 FakeIP Pool 相当于
```json
{
"ipPool": "198.18.0.0/15",
"poolSize": 65535
"fakedns": {
"ipPool": "198.18.0.0/15",
"poolSize": 65535
}
}
```
@@ -75,8 +83,10 @@ FakeDNS 将使用此选项指定的 IP 块分配地址。
```json
{
"ipPool": "fc00::/18",
"poolSize": 65535
"fakedns": {
"ipPool": "fc00::/18",
"poolSize": 65535
}
}
```
@@ -105,7 +115,7 @@ FakeDNS 本质上是一个 [DNS 服务器](./dns.md#serverobject),能够与任
"routing": {
"rules": [
{
"inboundTag": ["dns-in"], // 劫持来自 DNS 查询入口的 DNS 流量,或劫持来自透明代理入站的 DNS 流量。
"inboundTag": ["xxx"], // 劫持来自 DNS 查询入口的 DNS 流量,或劫持来自透明代理入站的 DNS 流量。
"port": 53,
"outboundTag": "dns-out"
}
@@ -119,10 +129,18 @@ FakeDNS 本质上是一个 [DNS 服务器](./dns.md#serverobject),能够与任
另外,你需要在**客户端**接收需代理流量的入站中开启 `Sniffing`,并使用 `fakedns` 目标地址重置。
```json
"sniffing": {
"enabled": true,
"destOverride": ["fakedns"], // 使用 "fakedns",或与其它 sniffer 搭配使用
"metadataOnly": false // 此项为 true 时 destOverride 仅可使用 fakedns
{
"inbounds": [
{
// ...
// [!code focus:5]
"sniffing": {
"enabled": true,
"destOverride": ["fakedns"], // 使用 "fakedns",或与其它 sniffer 搭配使用
"metadataOnly": false // 此项为 true 时 destOverride 仅可使用 fakedns
}
}
]
}
```
@@ -138,26 +156,29 @@ FakeDNS 本质上是一个 [DNS 服务器](./dns.md#serverobject),能够与任
```json
{
"servers": [
{
"address": "fakedns",
"domains": [
// 与下方分流所用的内容一致
"geosite:cn",
"domain:example.com"
]
},
{
"address": "1.2.3.4",
"domains": ["geosite:cn"],
"expectIPs": ["geoip:cn"]
},
{
"address": "1.1.1.1",
"domains": ["domain:example.com"]
},
"8.8.8.8"
]
"dns": {
"servers": [
// [!code focus:13]
{
"address": "fakedns",
"domains": [
// 与下方分流所用的内容一致
"geosite:cn",
"domain:example.com"
]
},
{
"address": "1.2.3.4",
"domains": ["geosite:cn"],
"expectIPs": ["geoip:cn"]
},
{
"address": "1.1.1.1",
"domains": ["domain:example.com"]
},
"8.8.8.8"
]
}
}
```
@@ -167,13 +188,15 @@ FakeDNS 本质上是一个 [DNS 服务器](./dns.md#serverobject),能够与任
```json
{
"servers": [
"fakedns",
{
"address": "1.2.3.4",
"domains": ["domain:do-not-use-fakedns.com"]
}
]
"dns": {
"servers": [
"fakedns",
{
"address": "1.2.3.4",
"domains": ["domain:do-not-use-fakedns.com"]
}
]
}
}
```
@@ -183,12 +206,14 @@ FakeDNS 本质上是一个 [DNS 服务器](./dns.md#serverobject),能够与任
```json
{
"servers": [
"1.2.3.4",
{
"address": "fakedns",
"domains": ["domain:only-this-use-fakedns.com"]
}
]
"dns": {
"servers": [
"1.2.3.4",
{
"address": "fakedns",
"domains": ["domain:only-this-use-fakedns.com"]
}
]
}
}
```
+90 -65
View File
@@ -12,24 +12,28 @@ FakeDNS may pollute the local DNS cache, causing "no network access" after Xray
```json
{
"ipPool": "198.18.0.0/16",
"poolSize": 65535
"fakedns": {
"ipPool": "198.18.0.0/16",
"poolSize": 65535
}
}
```
`FakeDnsObject` can also be configured as an array containing multiple FakeIP Pools. When a DNS query request is received, FakeDNS will return a set of FakeIPs derived from multiple FakeIP Pools simultaneously.
```json
[
{
"ipPool": "198.18.0.0/15",
"poolSize": 65535
},
{
"ipPool": "fc00::/18",
"poolSize": 65535
}
]
{
"fakedns": [
{
"ipPool": "198.18.0.0/15",
"poolSize": 65535
},
{
"ipPool": "fc00::/18",
"poolSize": 65535
}
]
}
```
> `ipPool`: CIDR
@@ -50,24 +54,28 @@ If `fakedns` is set in the `dns` item of the configuration file but `FakeDnsObje
When `queryStrategy` is `UseIP`, the initialized FakeIP Pool is equivalent to:
```json
[
{
"ipPool": "198.18.0.0/15",
"poolSize": 32768
},
{
"ipPool": "fc00::/18",
"poolSize": 32768
}
]
{
"fakedns": [
{
"ipPool": "198.18.0.0/15",
"poolSize": 32768
},
{
"ipPool": "fc00::/18",
"poolSize": 32768
}
]
}
```
When `queryStrategy` is `UseIPv4`, the initialized FakeIP Pool is equivalent to:
```json
{
"ipPool": "198.18.0.0/15",
"poolSize": 65535
"fakedns": {
"ipPool": "198.18.0.0/15",
"poolSize": 65535
}
}
```
@@ -75,8 +83,10 @@ When `queryStrategy` is `UseIPv6`, the initialized FakeIP Pool is equivalent to:
```json
{
"ipPool": "fc00::/18",
"poolSize": 65535
"fakedns": {
"ipPool": "fc00::/18",
"poolSize": 65535
}
}
```
@@ -105,7 +115,7 @@ It only works when DNS queries are routed to FakeDNS.
"routing": {
"rules": [
{
"inboundTag": ["dns-in"], // Hijack DNS traffic from DNS query entry points, or hijack DNS traffic from transparent proxy inbounds.
"inboundTag": ["xxx"], // Hijack DNS traffic from DNS query entry points, or hijack DNS traffic from transparent proxy inbounds.
"port": 53,
"outboundTag": "dns-out"
}
@@ -119,10 +129,18 @@ When an external DNS request enters the FakeDNS component, it returns an IP addr
Additionally, you need to enable `Sniffing` on the inbound of the **client** that receives traffic to be proxied, and use `fakedns` for destination address resetting.
```json
"sniffing": {
"enabled": true,
"destOverride": ["fakedns"], // Use "fakedns", or combine with other sniffers
"metadataOnly": false // When this is true, destOverride can only use fakedns
{
"inbounds": [
{
// ...
// [!code focus:5]
"sniffing": {
"enabled": true,
"destOverride": ["fakedns"], // Use "fakedns", or combine with other sniffers
"metadataOnly": false // When this is true, destOverride can only use fakedns
}
}
]
}
```
@@ -138,26 +156,29 @@ When using DNS routing (traffic splitting), to ensure `fakedns` has high priorit
```json
{
"servers": [
{
"address": "fakedns",
"domains": [
// Consistent with the content used for routing below
"geosite:cn",
"domain:example.com"
]
},
{
"address": "1.2.3.4",
"domains": ["geosite:cn"],
"expectIPs": ["geoip:cn"]
},
{
"address": "1.1.1.1",
"domains": ["domain:example.com"]
},
"8.8.8.8"
]
"dns": {
"servers": [
// [!code focus:13]
{
"address": "fakedns",
"domains": [
// Consistent with the content used for routing below
"geosite:cn",
"domain:example.com"
]
},
{
"address": "1.2.3.4",
"domains": ["geosite:cn"],
"expectIPs": ["geoip:cn"]
},
{
"address": "1.1.1.1",
"domains": ["domain:example.com"]
},
"8.8.8.8"
]
}
}
```
@@ -167,13 +188,15 @@ If you do not want certain domains to use FakeDNS, you can add `domains` configu
```json
{
"servers": [
"fakedns",
{
"address": "1.2.3.4",
"domains": ["domain:do-not-use-fakedns.com"]
}
]
"dns": {
"servers": [
"fakedns",
{
"address": "1.2.3.4",
"domains": ["domain:do-not-use-fakedns.com"]
}
]
}
}
```
@@ -183,12 +206,14 @@ If you want only certain domains to use FakeDNS, you can add `domains` configura
```json
{
"servers": [
"1.2.3.4",
{
"address": "fakedns",
"domains": ["domain:only-this-use-fakedns.com"]
}
]
"dns": {
"servers": [
"1.2.3.4",
{
"address": "fakedns",
"domains": ["domain:only-this-use-fakedns.com"]
}
]
}
}
```
+90 -65
View File
@@ -12,8 +12,10 @@ FakeDNS может загрязнить локальный DNS-кэш, что м
```json
{
"ipPool": "198.18.0.0/16",
"poolSize": 65535
"fakedns": {
"ipPool": "198.18.0.0/16",
"poolSize": 65535
}
}
```
@@ -21,16 +23,18 @@ FakeDNS может загрязнить локальный DNS-кэш, что м
При получении DNS-запроса FakeDNS вернет набор FakeIP, полученных из нескольких пулов FakeIP.
```json
[
{
"ipPool": "198.18.0.0/15",
"poolSize": 65535
},
{
"ipPool": "fc00::/18",
"poolSize": 65535
}
]
{
"fakedns": [
{
"ipPool": "198.18.0.0/15",
"poolSize": 65535
},
{
"ipPool": "fc00::/18",
"poolSize": 65535
}
]
}
```
> `ipPool`: CIDR
@@ -53,24 +57,28 @@ FakeDNS будет использовать этот блок IP-адресов
Если `queryStrategy` равен `UseIP`, инициализированный пул FakeIP будет эквивалентен:
```json
[
{
"ipPool": "198.18.0.0/15",
"poolSize": 32768
},
{
"ipPool": "fc00::/18",
"poolSize": 32768
}
]
{
"fakedns": [
{
"ipPool": "198.18.0.0/15",
"poolSize": 32768
},
{
"ipPool": "fc00::/18",
"poolSize": 32768
}
]
}
```
Если `queryStrategy` равен `UseIPv4`, инициализированный пул FakeIP будет эквивалентен:
```json
{
"ipPool": "198.18.0.0/15",
"poolSize": 65535
"fakedns": {
"ipPool": "198.18.0.0/15",
"poolSize": 65535
}
}
```
@@ -78,8 +86,10 @@ FakeDNS будет использовать этот блок IP-адресов
```json
{
"ipPool": "fc00::/18",
"poolSize": 65535
"fakedns": {
"ipPool": "fc00::/18",
"poolSize": 65535
}
}
```
@@ -108,7 +118,7 @@ FakeDNS будет использовать этот блок IP-адресов
"routing": {
"rules": [
{
"inboundTag": ["dns-in"], // Перехват DNS-трафика, поступающего от DNS-входа или от входящего подключения прозрачного прокси.
"inboundTag": ["xxx"], // Перехват DNS-трафика, поступающего от DNS-входа или от входящего подключения прозрачного прокси.
"port": 53,
"outboundTag": "dns-out"
}
@@ -122,10 +132,18 @@ FakeDNS будет использовать этот блок IP-адресов
Кроме того, вам нужно включить `Sniffing` во входящем подключении, которое принимает трафик, который нужно проксировать, и использовать `fakedns` для замены целевого адреса **на стороне клиента**.
```json
"sniffing": {
"enabled": true,
"destOverride": ["fakedns"], // Используйте "fakedns" или в сочетании с другими снифферами.
"metadataOnly": false // Если этот параметр равен true, то в destOverride можно использовать только fakedns.
{
"inbounds": [
{
// ...
// [!code focus:5]
"sniffing": {
"enabled": true,
"destOverride": ["fakedns"], // Используйте "fakedns" или в сочетании с другими снифферами.
"metadataOnly": false // Если этот параметр равен true, то в destOverride можно использовать только fakedns.
}
}
]
}
```
@@ -141,26 +159,29 @@ FakeDNS будет использовать этот блок IP-адресов
```json
{
"servers": [
{
"address": "fakedns",
"domains": [
// То же самое, что и в разделе разделения DNS ниже.
"geosite:cn",
"domain:example.com"
]
},
{
"address": "1.2.3.4",
"domains": ["geosite:cn"],
"expectIPs": ["geoip:cn"]
},
{
"address": "1.1.1.1",
"domains": ["domain:example.com"]
},
"8.8.8.8"
]
"dns": {
"servers": [
// [!code focus:13]
{
"address": "fakedns",
"domains": [
// То же самое, что и в разделе разделения DNS ниже.
"geosite:cn",
"domain:example.com"
]
},
{
"address": "1.2.3.4",
"domains": ["geosite:cn"],
"expectIPs": ["geoip:cn"]
},
{
"address": "1.1.1.1",
"domains": ["domain:example.com"]
},
"8.8.8.8"
]
}
}
```
@@ -170,13 +191,15 @@ FakeDNS будет использовать этот блок IP-адресов
```json
{
"servers": [
"fakedns",
{
"address": "1.2.3.4",
"domains": ["domain:do-not-use-fakedns.com"]
}
]
"dns": {
"servers": [
"fakedns",
{
"address": "1.2.3.4",
"domains": ["domain:do-not-use-fakedns.com"]
}
]
}
}
```
@@ -186,12 +209,14 @@ FakeDNS будет использовать этот блок IP-адресов
```json
{
"servers": [
"1.2.3.4",
{
"address": "fakedns",
"domains": ["domain:only-this-use-fakedns.com"]
}
]
"dns": {
"servers": [
"1.2.3.4",
{
"address": "fakedns",
"domains": ["domain:only-this-use-fakedns.com"]
}
]
}
}
```