smartdns
smartdns copied to clipboard
统计一下”自动配置dnsmasq“故障
翻了一下最近报告"自动配置dnsmasq故障"的都不能完全证实是smartdns的问题。常见有其他app争先修改dnsmasq配置,smardns版本错误等。
目前我遇到的smartdns 自动配置 dnsmasq故障如下:
openwrt 21.02 x86_64 官方原版 smartdns 37.2.10 + luci-app-smartdns 38.0.1 js版(来源:github action 自动编译)
当smartdns和dnsmasq具有以下配置时
root@OpenWrt:~# uci show dhcp
dhcp.@dnsmasq[0]=dnsmasq
dhcp.@dnsmasq[0].localise_queries='1'
dhcp.@dnsmasq[0].local='/lan/'
dhcp.@dnsmasq[0].domain='lan'
dhcp.@dnsmasq[0].expandhosts='1'
dhcp.@dnsmasq[0].readethers='1'
dhcp.@dnsmasq[0].leasefile='/tmp/dhcp.leases'
dhcp.@dnsmasq[0].ednspacket_max='1232'
dhcp.@dnsmasq[0].localservice='0'
dhcp.@dnsmasq[0].nonwildcard='0'
dhcp.@dnsmasq[0].port='5330'
dhcp.@dnsmasq[0].rebind_localhost='1'
dhcp.@dnsmasq[0].rebind_protection='1'
dhcp.@dnsmasq[0].domainneeded='1'
(以下省略)
root@OpenWrt:~# uci show smartdns
smartdns.@smartdns[0]=smartdns
smartdns.@smartdns[0].enabled='1'
smartdns.@smartdns[0].server_name='smartdns'
smartdns.@smartdns[0].serve_expired='0'
smartdns.@smartdns[0].seconddns_tcp_server='1'
smartdns.@smartdns[0].seconddns_no_speed_check='0'
smartdns.@smartdns[0].seconddns_no_rule_addr='0'
smartdns.@smartdns[0].seconddns_no_rule_nameserver='0'
smartdns.@smartdns[0].seconddns_no_rule_ipset='0'
smartdns.@smartdns[0].seconddns_no_rule_soa='0'
smartdns.@smartdns[0].seconddns_no_dualstack_selection='0'
smartdns.@smartdns[0].seconddns_no_cache='0'
smartdns.@smartdns[0].force_aaaa_soa='0'
smartdns.@smartdns[0].rr_ttl='10'
smartdns.@smartdns[0].rr_ttl_min='10'
smartdns.@smartdns[0].rr_ttl_max='600'
smartdns.@smartdns[0].rr_ttl_reply_max='600'
smartdns.@smartdns[0].tcp_server='1'
smartdns.@smartdns[0].dualstack_ip_selection='0'
smartdns.@smartdns[0].cache_size='4096'
smartdns.@smartdns[0].force_https_soa='0'
smartdns.@smartdns[0].seconddns_force_aaaa_soa='0'
smartdns.@smartdns[0].coredump='0'
smartdns.@smartdns[0].resolve_local_hostnames='0'
smartdns.@smartdns[0].ipv6_server='1'
smartdns.@smartdns[0].prefetch_domain='1'
smartdns.@smartdns[0].auto_set_dnsmasq='0'
smartdns.@smartdns[0].seconddns_port='5300'
smartdns.@smartdns[0].port='53'
smartdns.@smartdns[0].old_port='53'
将smartdns端口号改为非53,勾选”自动设置Dnsmasq“保存并应用,必然提示”重定向dnsmasq到smartdns失败“(故障可以重现)。 此时再检查设置
root@OpenWrt:~# uci show dhcp
dhcp.@dnsmasq[0]=dnsmasq
dhcp.@dnsmasq[0].localise_queries='1'
dhcp.@dnsmasq[0].local='/lan/'
dhcp.@dnsmasq[0].domain='lan'
dhcp.@dnsmasq[0].expandhosts='1'
dhcp.@dnsmasq[0].readethers='1'
dhcp.@dnsmasq[0].leasefile='/tmp/dhcp.leases'
dhcp.@dnsmasq[0].ednspacket_max='1232'
dhcp.@dnsmasq[0].localservice='0'
dhcp.@dnsmasq[0].nonwildcard='0'
dhcp.@dnsmasq[0].port='5330'
dhcp.@dnsmasq[0].rebind_localhost='1'
dhcp.@dnsmasq[0].rebind_protection='1'
dhcp.@dnsmasq[0].domainneeded='1'
(以下省略)
root@OpenWrt:~# uci show smartdns
smartdns.@smartdns[0]=smartdns
smartdns.@smartdns[0].enabled='1'
smartdns.@smartdns[0].server_name='smartdns'
smartdns.@smartdns[0].serve_expired='0'
smartdns.@smartdns[0].seconddns_tcp_server='1'
smartdns.@smartdns[0].seconddns_no_speed_check='0'
smartdns.@smartdns[0].seconddns_no_rule_addr='0'
smartdns.@smartdns[0].seconddns_no_rule_nameserver='0'
smartdns.@smartdns[0].seconddns_no_rule_ipset='0'
smartdns.@smartdns[0].seconddns_no_rule_soa='0'
smartdns.@smartdns[0].seconddns_no_dualstack_selection='0'
smartdns.@smartdns[0].seconddns_no_cache='0'
smartdns.@smartdns[0].force_aaaa_soa='0'
smartdns.@smartdns[0].rr_ttl='10'
smartdns.@smartdns[0].rr_ttl_min='10'
smartdns.@smartdns[0].rr_ttl_max='600'
smartdns.@smartdns[0].rr_ttl_reply_max='600'
smartdns.@smartdns[0].tcp_server='1'
smartdns.@smartdns[0].dualstack_ip_selection='0'
smartdns.@smartdns[0].cache_size='4096'
smartdns.@smartdns[0].force_https_soa='0'
smartdns.@smartdns[0].seconddns_force_aaaa_soa='0'
smartdns.@smartdns[0].coredump='0'
smartdns.@smartdns[0].resolve_local_hostnames='0'
smartdns.@smartdns[0].ipv6_server='1'
smartdns.@smartdns[0].prefetch_domain='1'
smartdns.@smartdns[0].seconddns_port='5300'
smartdns.@smartdns[0].port='5321'
smartdns.@smartdns[0].auto_set_dnsmasq='1'
smartdns.@smartdns[0].old_port='5321'
53端口的情况,你的dnsmasq的配置有问题。 53端口的情况,dnsmasq的port会被强制设置为0,表示关闭dnsmasq的dns功能。其他项目你没展示,没看到是否还有问题。 非53端口的情况。dnsmasq的server项目应该要被强制设置为127.0.0.1#[smartdnsport]
而你这两种情况,都有问题。 如果确认用的是最新版本,可以排查下是其他什么软件修改了dnsmasq的配置。
因为我这里是验证是没有问题的。
而你这两种情况,都有问题。 如果确认用的是最新版本,可以排查下是其他什么软件修改了dnsmasq的配置。
证实没有其他软件修改。最新js版本。
- 当smartdns端口配置为53且不勾选”自动设置dnsmasq“时,smartdns不会修改dnsmasq的非53端口号为0(设计上不是这样吗?预期会改吗?);
- 当smartdns端口号**由53改为非53且同时勾选”自动设置dnsmasq“**时,必然出现”重定向dnsmasq到smartdns失败“(总是重现)。
我这边openwrt 22.03验证是正常的。 对于第2个,提交到openwrt的版本提示错误,功能是正常的,这个最新代码在前几天已经修正。这个修正已经提交openwrt,目前还没合入 。
snapshot版本:https://downloads.openwrt.org/snapshots/packages/
设置53端口
root@OpenWrt:~# uci show smartdns
smartdns.@smartdns[0]=smartdns
smartdns.@smartdns[0].server_name='smartdns'
smartdns.@smartdns[0].tcp_server='1'
smartdns.@smartdns[0].ipv6_server='1'
smartdns.@smartdns[0].dualstack_ip_selection='1'
smartdns.@smartdns[0].serve_expired='1'
smartdns.@smartdns[0].resolve_local_hostnames='1'
smartdns.@smartdns[0].auto_set_dnsmasq='1'
smartdns.@smartdns[0].force_aaaa_soa='0'
smartdns.@smartdns[0].force_https_soa='0'
smartdns.@smartdns[0].rr_ttl_min='600'
smartdns.@smartdns[0].seconddns_port='6553'
smartdns.@smartdns[0].seconddns_tcp_server='1'
smartdns.@smartdns[0].seconddns_no_speed_check='0'
smartdns.@smartdns[0].seconddns_no_rule_addr='0'
smartdns.@smartdns[0].seconddns_no_rule_nameserver='0'
smartdns.@smartdns[0].seconddns_no_rule_ipset='0'
smartdns.@smartdns[0].seconddns_no_rule_soa='0'
smartdns.@smartdns[0].seconddns_no_dualstack_selection='0'
smartdns.@smartdns[0].seconddns_no_cache='0'
smartdns.@smartdns[0].seconddns_force_aaaa_soa='0'
smartdns.@smartdns[0].coredump='0'
smartdns.@smartdns[0].enabled='1'
smartdns.@smartdns[0].prefetch_domain='1'
smartdns.@smartdns[0].port='53'
smartdns.@smartdns[0].old_port='53'
dnsmasq配置
dhcp.@dnsmasq[0]=dnsmasq
dhcp.@dnsmasq[0].boguspriv='1'
dhcp.@dnsmasq[0].filterwin2k='0'
dhcp.@dnsmasq[0].localise_queries='1'
dhcp.@dnsmasq[0].rebind_localhost='1'
dhcp.@dnsmasq[0].local='/lan/'
dhcp.@dnsmasq[0].domain='lan'
dhcp.@dnsmasq[0].expandhosts='1'
dhcp.@dnsmasq[0].nonegcache='0'
dhcp.@dnsmasq[0].authoritative='1'
dhcp.@dnsmasq[0].readethers='1'
dhcp.@dnsmasq[0].leasefile='/tmp/dhcp.leases'
dhcp.@dnsmasq[0].resolvfile='/tmp/resolv.conf.d/resolv.conf.auto'
dhcp.@dnsmasq[0].nonwildcard='1'
dhcp.@dnsmasq[0].localservice='1'
dhcp.@dnsmasq[0].ednspacket_max='1232'
dhcp.@dnsmasq[0].rebind_protection='1'
dhcp.@dnsmasq[0].domainneeded='1'
dhcp.@dnsmasq[0].port='0'
dhcp.lan=dhcp
dhcp.lan.interface='lan'
dhcp.lan.start='100'
dhcp.lan.limit='150'
dhcp.lan.leasetime='12h'
dhcp.lan.dhcpv4='server'
dhcp.lan.dhcpv6='server'
dhcp.lan.ra='server'
dhcp.lan.ra_flags='managed-config' 'other-config'
dhcp.lan.dhcp_option='6,10.9.0.1'
dhcp.wan=dhcp
dhcp.wan.interface='wan'
dhcp.wan.ignore='1'
dhcp.odhcpd=odhcpd
dhcp.odhcpd.maindhcp='0'
dhcp.odhcpd.leasefile='/tmp/hosts/odhcpd'
dhcp.odhcpd.leasetrigger='/usr/sbin/odhcpd-update'
dhcp.odhcpd.loglevel='4'
dnsmasq生成的配置
# auto-generated config file from /etc/config/dhcp
conf-file=/etc/dnsmasq.conf
dhcp-authoritative
domain-needed
localise-queries
read-ethers
enable-ubus=dnsmasq
expand-hosts
bind-dynamic
local-service
port=0
edns-packet-max=1232
domain=lan
local=/lan/
addn-hosts=/tmp/hosts
dhcp-leasefile=/tmp/dhcp.leases
resolv-file=/tmp/resolv.conf.d/resolv.conf.auto
stop-dns-rebind
rebind-localhost-ok
dhcp-broadcast=tag:needs-broadcast
conf-dir=/tmp/dnsmasq.d
user=dnsmasq
group=dnsmasq
dhcp-ignore-names=tag:dhcp_bogus_hostname
conf-file=/usr/share/dnsmasq/dhcpbogushostname.conf
bogus-priv
conf-file=/usr/share/dnsmasq/rfc6761.conf
dhcp-range=set:lan,10.9.0.100,10.9.0.249,255.255.255.0,12h
dhcp-option=lan,6,10.9.0.1
用的是这边的版本,https://github.com/pymumu/smartdns/commit/33ead3afbdf7d2bcf124da6cb48d46124703a7b2 这个comment
我这边验证的时候,都只会基于原版openwrt验证的,都是验证正常才会提交代码的。 非原版,或安装了额外的软件,都有可能造成冲突。这个需要提供相关的信息才能定位。
我这边验证的时候,都只会基于原版openwrt验证的,都是验证正常才会提交代码的。 非原版,或安装了额外的软件,都有可能造成冲突。这个需要提供相关的信息才能定位。
顾左右而言他。我这个情况是已知问题,这边代码没更新,还是无法重现?还是需要提供更多信息?

我这边已经验证多次了,没有任何问题,上面是截图。 可以
- 先确认下版本是否安装正确。
- 看一下安装的其他软件,可以暂时关闭下,在验证看看。
下载这个 https://downloads.openwrt.org/snapshots/targets/x86/64/openwrt-x86-64-generic-ext4-combined-efi.img.gz 解压后转为vmdk格式然后直接导入虚拟机内开机。默认不带uci,opkg update && opkg install luci后,发现版本是OpenWrt SNAPSHOT r20667-1afd0fefd2 / LuCI Master git-22.245.77360-10bcb22。安装这边代码对应的最新版 smartdns 和 luci-app-smartdns (js版),git action自动编译。然后进行如下调整:
- 关闭ipv6(由于内网冲突)
- dnsmasq端口改为5330
- smartdns随便添加一个上游,配置端口53,取消勾选”Automatically Set Dnsmasq“,然后点击”Save & Apply“。 此时:1. dnsmasq端口仍为5330(没有改成0)2. smartdns正确工作。
- 将smartdns端口改为5321,勾选”Automatically Set Dnsmasq“,然后点击”Save & Apply“。 此时:1.smardns提示”SmartDNS - RUNNING“,”Dnsmasq Forwared To Smartdns Failure“ 2. 观察dnsmasq,”DNS forwardings“是空的,说明的确没有正确配置dnsmasq。
好了这两个问题在原版21、22都可以重现了
第3个,重复你的操作,我这里是正常的。
root@OpenWrt:~# uci show dhcp | grep port
dhcp.@dnsmasq[0].port='0' <--端口修改为0
root@OpenWrt:~# uci show smartdns | grep auto
smartdns.@smartdns[0].auto_set_dnsmasq='0' <--禁用自动设置
root@OpenWrt:~# uci show smartdns | grep port
smartdns.@smartdns[0].seconddns_port='6553'
smartdns.@smartdns[0].port='53' <--53端口
smartdns.@smartdns[0].old_port='53'
第4个和你说过了,是已知问题,openwrt上游还没合入。这个提示不影响功能。 https://github.com/openwrt/luci/pull/5980
建议这边更新先。我这现在是自动编译然后本地自动更新的
最新代码,几天前就修改了重定向失败的提示。
https://github.com/pymumu/smartdns/commit/33ead3afbdf7d2bcf124da6cb48d46124703a7b2
另外,如果运行过js版本,并提示重定向失败的,清空下浏览器历史记录。然后再用最新的代码
这个提示不影响功能。
显然dnsmasq没有配置好,怎么会不影响功能呢?
最新代码,几天前就修改了重定向失败的提示。

证实当前用的就是这个版本。由于新装openwrt,不存在浏览器缓存问题
你看一下/etc/init.d/smartdns脚本,是否是最新版本。
证实是这个文件版本 https://github.com/pymumu/smartdns/blob/master/package/openwrt/files/etc/init.d/smartdns 9月1日更新的
执行下面的命令,将输出发一下。
/etc/init.d/smartdns stop
INIT_TRACE=1 /etc/init.d/smartdns start
log不止这么点,里面关键字也没有,是不是被截取了?如果没有的话,这个执行结果并不是最新脚本的结果。
root@OpenWrt:~# md5sum /etc/init.d/smartdns 9e9ed7f977703468f4ff00efb6a2cfaa /etc/init.d/smartdns
先确认下脚本md5是否一致。
没想到会超过2000行,putty没配那么大缓冲区。这是完整 的
以下操作基于上面dnsmasq有上游配置:
1.将smartdns端口号改为53,取消勾选”Automatically Set Dnsmasq“,然后点击”Save & Apply“。
此时:1. dnsmasq端口仍为5330(没有改成0)2.dnsmasq没有上游配置 3. smartdns正确工作。
2.将smartdns端口改为5321,勾选”Automatically Set Dnsmasq“,然后点击”Save & Apply“。
此时:1.smardns提示”SmartDNS - RUNNING“,”Dnsmasq Forwared To Smartdns Failure“ 2. dnsmasq没有上游配置
3.执行/etc/init.d/smartdns stop和INIT_TRACE=1 /etc/init.d/smartdns start
此时:1.smardns”Dnsmasq Forwared To Smartdns Failure“消失2.dnsmasq有DNS forwardings 127.0.0.1#5321配置
console.txt
试了几次,证实只有首次点击”Save & Apply“时,dnsmasq不能自动配置。重新应用就可以正常
那可能是openwrt的问题,可以用稳定版试试
那可能是openwrt的问题,可以用稳定版试试
花了一点时间把22.03跑起来了,用的这个 https://downloads.openwrt.org/releases/22.03.0/targets/x86/64/openwrt-22.03.0-x86-64-generic-ext4-combined-efi.img.gz 还是一样的现象,首次保存必然失败。
首次失败是什么情况?
首次失败是什么情况?
看不懂。上边说的都是同一个问题,21.02 22.03 22.245 都有
我这边确实没法复现。包括刷路由器固件后重新安装。我这边验证的时候,默认固件,只安装了smartdns 你后面发的那个完整的log,看了应该是正确设置dnsmasq的。 最好能明确出在openwrt下的复现步骤。
3. smartdns随便添加一个上游,配置端口53,取消勾选”Automatically Set Dnsmasq“,然后点击”Save & Apply“。 此时:1. dnsmasq端口仍为5330(没有改成0)2. smartdns正确工作。 4. 将smartdns端口改为5321,勾选”Automatically Set Dnsmasq“,然后点击”Save & Apply“。 此时:1.smardns提示”SmartDNS - RUNNING“,”Dnsmasq Forwared To Smartdns Failure“ 2. 观察dnsmasq,”DNS forwardings“是空的,说明的确没有正确配置dnsmasq。
1.将smartdns端口号改为53,取消勾选”Automatically Set Dnsmasq“,然后点击”Save & Apply“。 此时:1. dnsmasq端口仍为5330(没有改成0)2.dnsmasq没有上游配置 3. smartdns正确工作。 2.将smartdns端口改为5321,勾选”Automatically Set Dnsmasq“,然后点击”Save & Apply“。 此时:1.smardns提示”SmartDNS - RUNNING“,”Dnsmasq Forwared To Smartdns Failure“ 2. dnsmasq没有上游配置
这操作已经够详细了。加上主楼中文系统,三个操作过程都是一样的,只不过一开始发现问题是中文系统,后来都是新装没有中文语言包,所以按钮什么都是英文的。
目前猜测是加载配置顺序不正确(应先加载端口配置再改dnsmasq
最新代码修正了,可以获取验证下看看。