# DNS设置

{% hint style="info" %}

* MC强制开启DNS覆写功能，不可关闭
* <mark style="color:orange;">修改DNS有风险</mark>，不懂勿动
* 本功能提交修改后，<mark style="color:orange;">重启MC插件生效</mark>
  {% endhint %}

<figure><img src="https://1927080012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbElCPWLUN7JiinF0Ycv%2Fuploads%2FTEeNXavflEudZZQFpaYS%2F7.jpg?alt=media&#x26;token=80e1bb9e-94b7-4cad-93b1-02c103a14eca" alt=""><figcaption></figcaption></figure>

### <mark style="color:blue;">DNS方案：</mark>

#### DNS方案：

切换DNS配置方案，详情请参看[MihomoWiki-DNS](https://wiki.metacubex.one/config/dns/)

#### 黒名单设备解析服务器：

<mark style="color:$primary;">访问控制</mark>中不通过代理的设备使用的解析服务器（仅支持UDP-IP的DNS服务器）（<mark style="color:$primary;">仅Fake-ip模式可见</mark>）

#### 自定义DNS：

编辑Redir-Host或者Fake-IP配置文件，默认配置如下：

```yaml
# 默认Redir-Host配置:
dns:
  enable: true                      #开启DNS解析，必须开启，否则MC将无法解析
  ipv6: false                       #默认关闭，插件开启IP6支持口，自动打开
  listen: :23453                    #监听端口，不懂勿动
  enhanced-mode: redir-host         #DNS模式
  respect-rules: true               #DNS连接遵守Rule规则
  proxy-server-nameserver:          #节点解析服务器
    - 119.29.29.29
    - 223.5.5.5
  nameserver-policy:                #指定域名使用自定义DNS解析，支持udp/tcp/dot/doh
    "+.steampowered.com": "223.5.5.5"
    "geosite: gfw":
      - https://doh.dns.sb/dns-query 
      - tls://8.8.8.8:853
      - tls://unfiltered.adguard-dns.com
  nameserver:                       #默认DNS服务器，支持udp/tcp/dot/doh
    - https://doh.pub/dns-query
    - 223.5.5.5

# 默认Fake-ip配置:
dns:
  enable: true
  ipv6: false
  listen: :23453
  default-nameserver:                       #解析非IP的dns用的dns服务器,只支持纯IP
    - 223.5.5.5
    - 119.29.29.29
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16              #Fake-ip解析ip4池
  fake-ip-range6: fdfe:dcba:9876::1/64      #Fake-ip解析ip6池
  fake-ip-filter-mode: whitelist            #过滤模式，默认白名单
  fake-ip-filter:                           #过滤名单
    - 'geosite: gfw'
  nameserver:                               #默认DNS服务器(国内)
    - 119.29.29.29
    - 223.5.5.5
    - 180.76.76.76
    
```

<figure><img src="https://1927080012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbElCPWLUN7JiinF0Ycv%2Fuploads%2FBzEgWVnNbvwODhTFXVXj%2F7a.jpg?alt=media&#x26;token=2032c68e-b6d5-4ba9-8cd8-5800e7d75813" alt=""><figcaption></figcaption></figure>

### <mark style="color:blue;">其他设置：</mark>

#### DNS劫&#x6301;**：**

劫持路由下所有设备的DNS查询流量（UDP53端口）给内核，强烈建议开启

#### 路由自身DNS使用Clash设&#x5B9A;**：**

路由自己的网络访问的DNS使用MC设定

#### 清除路由自定义DN&#x53;**：**

清除路由【内部网络(LAN)】-【DHCP服务器】中的DNS设置，防止设备端继承该DNS设定，导致解析错误

#### Sniffer域名嗅&#x63A2;**：**

启用域名嗅探功能，详见[MihomoWiki-域名嗅探](https://wiki.metacubex.one/config/sniff/)，默认配置如下：

```yaml
sniffer:
  enable: true
  force-dns-mapping: false
  parse-pure-ip: true
  override-destination: true
  sniff:
    TLS:
      ports: [443, 8443]    
    HTTP:   
      ports: [80, 8080-8880]
      override-destination: false
  force-domain:
    - '+.v2ex.com'
  skip-domain:
    - 'Mijia Cloud'
    - 'dlg.io.mi.com'
    - '+.apple.com'

```

#### 自定义Hosts：

编辑自定义Hosts，详见[MihomoWiki-Hosts](https://wiki.metacubex.one/config/dns/hosts/)，默认配置如下：

```yaml
hosts:
  services.googleapis.cn: 74.125.193.94
  time.android.com: 203.107.6.88
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mcreadme.gitbook.io/mc/base/dns.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
