diff --git a/docs/configuration/inbound/dns.md b/docs/configuration/inbound/dns.md deleted file mode 100644 index 49b47661..00000000 --- a/docs/configuration/inbound/dns.md +++ /dev/null @@ -1,44 +0,0 @@ -`dns` inbound is a DNS server. - -### Structure - -```json -{ - "inbounds": [ - { - "type": "dns", - "tag": "dns-in", - - "listen": "::", - "listen_port": 5353, - "network": "udp" - } - ] -} -``` - -!!! note "" - - There are no outbound connections by the DNS inbound, all requests are handled internally. - -### Listen Fields - -#### listen - -==Required== - -Listen address. - -#### listen_port - -==Required== - -Listen port. - -### DNS Fields - -#### network - -Listen network, one of `tcp` `udp`. - -Both if empty. \ No newline at end of file diff --git a/docs/configuration/inbound/index.md b/docs/configuration/inbound/index.md index a7868396..487d8ec9 100644 --- a/docs/configuration/inbound/index.md +++ b/docs/configuration/inbound/index.md @@ -23,7 +23,6 @@ | `tun` | [Tun](./tun) | | `redirect` | [Redirect](./redirect) | | `tproxy` | [TProxy](./tproxy) | -| `dns` | [DNS](./dns) | #### tag diff --git a/docs/configuration/inbound/tun.md b/docs/configuration/inbound/tun.md index 183b49e3..435fcf93 100644 --- a/docs/configuration/inbound/tun.md +++ b/docs/configuration/inbound/tun.md @@ -15,7 +15,6 @@ "inet6_address": "fdfe:dcba:9876::1/128", "mtu": 1500, "auto_route": true, - "hijack_dns": true, "sniff": true, "sniff_override_destination": false, @@ -49,10 +48,6 @@ Set the default route to the Tun. To avoid traffic loopback, set `route.auto_detect_interface` or `route.default_interface` or `outbound.bind_interface` -#### hijack_dns - -Hijack TCP/UDP DNS requests to the built-in DNS adapter. - ### Listen Fields #### sniff diff --git a/docs/configuration/outbound/dns.md b/docs/configuration/outbound/dns.md new file mode 100644 index 00000000..cadc8776 --- /dev/null +++ b/docs/configuration/outbound/dns.md @@ -0,0 +1,22 @@ +`dns` outbound is a DNS server. + +### Structure + +```json +{ + "outbounds": [ + { + "type": "dns", + "tag": "dns-out" + } + ] +} +``` + +!!! note "" + + There are no outbound connections by the DNS outbound, all requests are handled internally. + +### Fields + +No fields. \ No newline at end of file diff --git a/docs/configuration/outbound/index.md b/docs/configuration/outbound/index.md index 059bb985..bd547acc 100644 --- a/docs/configuration/outbound/index.md +++ b/docs/configuration/outbound/index.md @@ -20,6 +20,7 @@ | `socks` | [Socks](./socks) | | `http` | [HTTP](./http) | | `shadowsocks` | [Shadowsocks](./shadowsocks) | +| `dns` | [DNS](./dns) | | `selector` | [Selector](./selector) | | `urltest` | [URLTest](./urltest) | diff --git a/docs/configuration/route/sniff.md b/docs/configuration/route/sniff.md index 73593d82..2ba2c251 100644 --- a/docs/configuration/route/sniff.md +++ b/docs/configuration/route/sniff.md @@ -2,9 +2,10 @@ If enabled in the inbound, the protocol and domain name (if present) of by the c #### Supported Protocols -| Network | Protocol | Domain Name | -|:---------:|:----------:|:-------------:| -| TCP | HTTP | Host | -| TCP | TLS | Server Name | -| UDP | QUIC | Server Name | -| UDP | STUN | / | \ No newline at end of file +| Network | Protocol | Domain Name | +|:-------:|:--------:|:-----------:| +| TCP | HTTP | Host | +| TCP | TLS | Server Name | +| UDP | QUIC | Server Name | +| UDP | STUN | / | +| TCP/UDP | DNS | / | \ No newline at end of file diff --git a/docs/examples/dns-hijack.md b/docs/examples/dns-hijack.md new file mode 100644 index 00000000..ea7b2783 --- /dev/null +++ b/docs/examples/dns-hijack.md @@ -0,0 +1,67 @@ +# DNS Hijack + +#### Sniff Mode + +```json +{ + "inbounds": [ + { + "type": "tun", + "inet4_address": "172.19.0.1/30", + "auto_route": true, + "sniff": true // required + } + ], + "outbounds": [ + { + "type": "direct" + }, + { + "type": "dns", + "tag": "dns-out" + } + ], + "route": { + "rules": [ + { + "protocol": "dns", + "outbound": "dns-out" + } + ], + "auto_detect_interface": true + } +} +``` + +#### Port Mode + +```json +{ + "inbounds": [ + { + "type": "tun", + "inet4_address": "172.19.0.1/30", + "auto_route": true, + "sniff": true // not required + } + ], + "outbounds": [ + { + "type": "direct" + }, + { + "type": "dns", + "tag": "dns-out" + } + ], + "route": { + "rules": [ + { + "port": 53, + "outbound": "dns-out" + } + ], + "auto_detect_interface": true + } +} +``` \ No newline at end of file diff --git a/docs/examples/index.md b/docs/examples/index.md index 859f2103..30bf76c4 100644 --- a/docs/examples/index.md +++ b/docs/examples/index.md @@ -4,4 +4,5 @@ Configuration examples for sing-box. * [Shadowsocks Server](./ss-server) * [Shadowsocks Client](./ss-client) -* [Shadowsocks Tun](./ss-tun) \ No newline at end of file +* [Shadowsocks Tun](./ss-tun) +* [DNS Hijack](./dns-hijack.md) \ No newline at end of file diff --git a/docs/examples/ss-tun.md b/docs/examples/ss-tun.md index 7584995e..e41b3d48 100644 --- a/docs/examples/ss-tun.md +++ b/docs/examples/ss-tun.md @@ -26,7 +26,6 @@ "type": "tun", "inet4_address": "172.19.0.1/30", "auto_route": true, - "hijack_dns": true, "sniff": true } ], @@ -46,10 +45,18 @@ { "type": "block", "tag": "block" + }, + { + "type": "dns", + "tag": "dns-out" } ], "route": { "rules": [ + { + "protocol": "dns", + "outbound": "dns-out" + }, { "geosite": "category-ads-all", "outbound": "block" diff --git a/mkdocs.yml b/mkdocs.yml index afc38471..fd0721e2 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -48,7 +48,6 @@ nav: - Tun: configuration/inbound/tun.md - Redirect: configuration/inbound/redirect.md - TProxy: configuration/inbound/tproxy.md - - DNS: configuration/inbound/dns.md - Outbound: - configuration/outbound/index.md - Direct: configuration/outbound/direct.md @@ -56,6 +55,7 @@ nav: - Socks: configuration/outbound/socks.md - HTTP: configuration/outbound/http.md - Shadowsocks: configuration/outbound/shadowsocks.md + - DNS: configuration/outbound/dns.md - Selector: configuration/outbound/selector.md - URLTest: configuration/outbound/urltest.md - Route: @@ -70,6 +70,7 @@ nav: - Shadowsocks Server: examples/ss-server.md - Shadowsocks Client: examples/ss-client.md - Shadowsocks Tun: examples/ss-tun.md + - DNS Hijack: examples/dns-hijack.md - Benchmark: benchmark.md markdown_extensions: - pymdownx.inlinehilite