hide:
将软件包(使用 WinSCP 等)上传到路由器的 /root 目录,执行如下命令安装
openwrt 24.10之后版本
apk add --allow-untrusted smartdns.1.yyyy.MM.dd-REL.xxxx.apk
apk add --allow-untrusted luci-app-smartdns-lite.1.yyyy.MM.dd-REL.all.apk
openwrt 24.10之前版本
opkg install smartdns.1.yyyy.MM.dd-REL.xxxx.ipk
opkg install luci-app-smartdns-lite.1.yyyy.MM.dd-REL.all.ipk
luci-app-smartdns.1.yyyy.MM.dd-REL.all-luci-compat-all.ipk。登录 OpenWrt 管理页面,打开 Services -> SmartDNS 进行配置。
Upstream Servers 增加上游 DNS 服务器配置,建议配置多个国内外 DNS 服务器。Domain Address 指定特定域名的 IP 地址,可用于广告屏蔽。登录 OpenWrt 管理界面,点击 Services -> SmartDNS -> port,设置端口号为53,smartdns会自动接管主DNS服务器。
执行
nslookup -querytype=ptr smartdns
查看命令结果中的 name 是否为 smartdns 或你的主机名,如果是则表示生效
$ nslookup -querytype=ptr smartdns
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
smartdns name = smartdns.
勾选配置页面中的 Enable(启用)来启动 SmartDNS。
若在此过程中发生异常,可使用如下命令还原dnsmasq为主DNS
uci delete dhcp.@dnsmasq[0].port
uci commit dhcp
/etc/init.d/dnsmasq restart