在玩转软路由的路上,很多人都会遇到两个头疼的问题:DNS 污染导致网页加载慢,以及DNS 泄露暴露了隐私。
今天给大家分享一套组合方案:MosDNS + OpenClash。
由 MosDNS 负责精准的国内外分流、去广告和秒开网页,OpenClash 负责底层核心代理解析。
两者的强强联手,不仅能实现丝滑的上网体验,还能完美通过防泄露测试。
下面是保姆级的配置全流程,直接抄作业即可!以下教程以iStoreOS为例:
首先,我们需要安装好所需的插件。这里提供一个一键安装脚本,登录你的 OpenWrt SSH 后台,直接运行以下命令:
推荐直接使用菜单模式,安装、更新、检查版本和卸载都在菜单里:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/slobys/openclash-auto-installer/main/menu.sh)"固定稳定版可使用 Release 标签,例如:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/slobys/openclash-auto-installer/v1.2.4/menu.sh)"如果 GitHub raw 访问慢,可用 jsDelivr:
sh -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/slobys/openclash-auto-installer@main/menu.sh)"菜单结构:
1. 检查插件更新
2. 安装插件
3. 卸载插件
0. 退出在动手之前,我们先花一分钟理清这套方案的 DNS 流向,知其然更要知其所以然:

通过这个闭环,所有的解析请求都会经过 MosDNS 的智能分流处理,确保国内流量直连、国外流量走代理解析。
进入iStoreOS后台,打开 MosDNS 配置界面。未提及的选项请一律保持默认。
启用:✅ 勾选
配置文件:内置预设
监听地址:0.0.0.0
监听端口:5335
远程 DNS 首选 IPv4:✅ 勾选
DNS 首选 IPv4:开启
自定义国内 DNS:开启
国内 DNS 服务器:请选择加密 DNS 服务器(如腾讯/阿里的 DoH)。
远程 DNS 服务器:请填入以下标准 DoH 地址:
https://cloudflare-dns.com/dns-query
https://dns.google/dns-query
参考下图:

为了榨干 DNS 解析性能并保障安全,请按如下参数配置:
参考下图:

接下来前往 OpenClash 插件设置。
本地 DNS 劫持:选择 使用Dnsmasq转发

自定义上游 DNS 服务器:✅ 勾选
往下滚动找到服务器添加区域,我们需要添加以下三条记录:
⚠️ 特别注意(新手易踩坑):
这里的阿里 DoH 和 腾讯 DoH 只是用来充当 Bootstrap DNS(引导 DNS),目的是为了首次接通网络、解析出节点域名的真实 IP。当网络正常接通后,请务必取消勾选这两条(只留 127.0.0.1),把国内外流量全部交由 MosDNS 去解析!
配置完成后,为了让所有规则和缓存生效,不建议只点“保存并应用”,最稳妥的方法是编写一个简单的脚本按顺序重启相关服务(或者直接重启软路由)。
在 SSH 中执行以下命令进行服务的平滑重启:
/etc/init.d/openclash stop
sleep 3
/etc/init.d/mosdns restart
sleep 5
/etc/init.d/dnsmasq restart
sleep 5
/etc/init.d/openclash start
sleep 15
通常情况下,上述配置会自动接管系统底层,但我们还是需要去 OpenWrt 的 网络-DHCP/DNS 界面确认一眼:
转发 -DNS转发:确认显示为 127.0.0.1#7874
Resolv和Hosts 文件- 忽略解析文件:✅ 勾选
配置得好不好,用数据说话。打开终端(Windows 的 CMD 或 Mac 的 Terminal),依次输入以下三条命令测试 DNS 链路:
dig @127.0.0.1 -p 5335 google.com
dig @127.0.0.1 -p 7874 google.com
# 注意:请将 192.168.1.254 替换为你实际的软路由 LAN 口 IP
dig @192.168.1.254 google.com 在iStoreOS后台的 SSH 或者 终端 里面测试用以下命令
# 测试 5335
busybox nslookup -port=5335 google.com 127.0.0.1
# 测试 7874
busybox nslookup -port=7874 google.com 127.0.0.1
# 测试网关 53 注意:请将 192.168.1.254 替换为你实际的软路由 LAN 口 IP
busybox nslookup google.com 192.168.1.254 SSH 或者 终端返回结果
root@iStoreOS:~# busybox nslookup -port=5335 google.com 127.0.0.1
Server: 127.0.0.1
Address: 127.0.0.1:5335
Non-authoritative answer:
Non-authoritative answer:
Name: google.com
Address: 142.250.21.138
Name: google.com
Address: 142.250.21.113
Name: google.com
Address: 142.250.21.102
Name: google.com
Address: 142.250.21.101
Name: google.com
Address: 142.250.21.139
Name: google.com
Address: 142.250.21.100
root@iStoreOS:~# busybox nslookup -port=7874 google.com 127.0.0.1
Server: 127.0.0.1
Address: 127.0.0.1:7874
Name: google.com
Address: 198.18.9.133
root@iStoreOS:~# busybox nslookup google.com 192.168.1.254
Server: 192.168.1.254
Address: 192.168.1.254:53
Name: google.com
Address: 198.18.9.1335335 端口 返回 真实境外 IP(代表 MosDNS 远程解析正常)
7874 端口 返回 198.18.x.x(Clash 的 Fake-IP 模式标志,说明代理解析正常)
软路由网关 IP 返回 198.18.x.x(说明客户端流量已完美通过 Dnsmasq 转发给 Clash)
最后,掏出浏览器,打开这两个网站进行最终的实战检测:
DNS 泄露测试测试网址:https://browserleaks.com/dns
完美标准:列表里只能看到 Cloudflare 或 Google 等国外安全 DNS 服务商,绝对不能出现你本地宽带运营商(如电信/联通/移动)的 IP
WebRTC测试测试网址:https://browserleaks.com/webrtc
完美标准:列表里Public IP Address,绝对不能出现你本地宽带运营商(如电信/联通/移动)的 IP
WebRTC Support Detection表显示
RTCPeerConnection ✔True
RTCDataChannel ✔True完美标准:根据你开启的 MosDNS 广告过滤规则,网页得分会显著提升。
#去广告规则地址
https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt
https://adguardteam.github.io/HostlistsRegistry/assets/filter_2.txt
https://adguardteam.github.io/HostlistsRegistry/assets/filter_29.txt
https://adguardteam.github.io/HostlistsRegistry/assets/filter_21.txt
https://raw.githubusercontent.com/xinggsf/Adblock-Plus-Rule/master/rule.txt
https://raw.githubusercontent.com/sjhgvr/oisd/refs/heads/main/dnsmasq2_big.txt
https://raw.githubusercontent.com/8680/GOODBYEADS/master/data/rules/dns.txt
#2026/05/18更新 使用下面几个规则 可以避免误拦截
https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt # AdGuard DNS filter
https://adguardteam.github.io/HostlistsRegistry/assets/filter_2.txt # AdAway Default Blocklist
https://adguardteam.github.io/HostlistsRegistry/assets/filter_21.txt # CHN: anti-AD
https://raw.githubusercontent.com/217heidai/adblockfilters/main/rules/adblockdns.txt # AdBlock DNS
至此,一套高效率、无污染、防泄露的 OpenWrt 网络环境就彻底打造完成了!赶紧刷新一下网页,享受丝滑的上网体验吧!
本文参考 [一瓶奶油] OpenClash + MosDNS防 DNS 泄露完整教程 视频而编写
墙裂推荐-YIY云 点击进入注册地址 - 延时低;某些地区测速500M/s+/可跑满千兆