SmartDNS是一个运行在本地的DNS服务器,SmartDNS接受本地客户端的DNS查询请求,从多个上游DNS服务器获取DNS查询结果,并将访问速度最快的结果返回给客户端,提高网络访问速度。 同时支持指定特定域名IP地址,并高性匹配,达到过滤广告的效果。
与dnsmasq的all-servers不同,smartdns返回的是访问速度最快的解析结果。 (详细差异请看FAQ)
支持树莓派,openwrt,华硕路由器,windows等设备。
软件效果展示
阿里DNS
使用阿里DNS查询百度IP,并检测结果。
pi@raspberrypi:~/code/smartdns_build $ nslookup www.baidu.com 223.5.5.5 Server: 223.5.5.5 Address: 223.5.5.5#53 Non-authoritative answer: www.baidu.com canonical name = www.a.shifen.com. Name: www.a.shifen.com Address: 180.97.33.108 Name: www.a.shifen.com Address: 180.97.33.107 pi@raspberrypi:~/code/smartdns_build $ ping 180.97.33.107 -c 2 PING 180.97.33.107 (180.97.33.107) 56(84) bytes of data. 64 bytes from 180.97.33.107: icmp_seq=1 ttl=55 time=24.3 ms 64 bytes from 180.97.33.107: icmp_seq=2 ttl=55 time=24.2 ms --- 180.97.33.107 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 24.275/24.327/24.380/0.164 ms pi@raspberrypi:~/code/smartdns_build $ ping 180.97.33.108 -c 2 PING 180.97.33.108 (180.97.33.108) 56(84) bytes of data. 64 bytes from 180.97.33.108: icmp_seq=1 ttl=55 time=31.1 ms 64 bytes from 180.97.33.108: icmp_seq=2 ttl=55 time=31.0 ms --- 180.97.33.108 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 31.014/31.094/31.175/0.193 ms
smartdns
使用SmartDNS查询百度IP,并检测结果。
pi@raspberrypi:~/code/smartdns_build $ nslookup www.baidu.com Server: 192.168.1.1 Address: 192.168.1.1#53 Non-authoritative answer: www.baidu.com canonical name = www.a.shifen.com. Name: www.a.shifen.com Address: 14.215.177.39 pi@raspberrypi:~/code/smartdns_build $ ping 14.215.177.39 -c 2 PING 14.215.177.39 (14.215.177.39) 56(84) bytes of data. 64 bytes from 14.215.177.39: icmp_seq=1 ttl=56 time=6.31 ms 64 bytes from 14.215.177.39: icmp_seq=2 ttl=56 time=5.95 ms --- 14.215.177.39 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 5.954/6.133/6.313/0.195 ms
从对比看出,smartdns找到访问www.baidu.com最快的IP地址,这样访问百度比阿里DNS速度快5倍。
下载配套安装包
一般LEDE/openwrt下载以下对应SmartDNS安装包即可
smartdns.xxxxxxxx.x86_64.ipk 支持x86_64路由器
luci-app-smartdns.xxxxxxxxx.xxxx.all.ipk openwrt管理统一界面
下载请前往Release页面:点击此处下载
openwrt/LEDE
- 安装将软件使用winscp上传到路由器的/root目录,执行如下命令安装
opkg install smartdns.xxxxxxxx.xxxx.ipk opkg install luci-app-smartdns.xxxxxxxx.xxxx.all.ipk
- 修改配置登录openwrt管理页面,打开
Services
->SmartDNS
进行配置。- 在
Upstream Servers
增加上游DNS服务器配置,建议配置多个国内外DNS服务器。 - 在
Domain Address
指定特定域名的IP地址,可用于广告屏蔽。
- 在
- 启用服务SmartDNS服务生效方法有两种,
一种是直接作为主DNS服务
;另一种是作为dnsmasq的上游
。
默认情况下,SmartDNS采用第一种方式。如下两种方式根据需求选择即可。 - 启用方法一:作为主DNS(默认方案)
- 启用smartdns的53端口重定向登录路由器,点击
Services
->SmartDNS
->redirect
,选择重定向53端口到SmartDNS
启用53端口转发。 - 检测转发服务是否配置成功使用
nslookup -querytype=ptr smartdns
查询域名
看命令结果中的name
项目是否显示为smartdns
或主机名
,如smartdns
则表示生效pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns Server: 192.168.1.1 Address: 192.168.1.1#53 Non-authoritative answer: smartdns name = smartdns.
- 界面提示重定向失败
- 检查iptable,ip6table命令是否正确安装。
- openwrt 15.01系统不支持IPV6重定向,如网络需要支持IPV6,请将DNSMASQ上游改为smartdns,或者将smartdns的端口改为53,并停用dnsmasq。
- LEDE之后系统,请安装IPV6的nat转发驱动。点击
system
->Software
,点击update lists
更新软件列表后,安装ip6tables-mod-nat
- 使用如下命令检查路由规则是否生效。
iptables -t nat -L PREROUTING | grep REDIRECT
- 如转发功能不正常,请使用方法二:作为DNSMASQ的上游。
- 启用smartdns的53端口重定向登录路由器,点击
- 方法二:作为DNSMASQ的上游
- 将dnsmasq的请求发送到smartdns登录路由器,点击
Services
->SmartDNS
->redirect
,选择作为dnsmasq的上游服务器
设置dnsmasq的上游服务器为smartdns。 - 检测上游服务是否配置成功
- 方法一:使用
nslookup -querytype=ptr smartdns
查询域名
看命令结果中的name
项目是否显示为smartdns
或主机名
,如smartdns
则表示生效
pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns Server: 192.168.1.1 Address: 192.168.1.1#53 Non-authoritative answer: smartdns name = smartdns.
- 方法二:使用
nslookup
查询www.baidu.com
域名,查看结果中百度的IP地址是否只有一个
,如有多个IP地址返回,则表示未生效,请多尝试几个域名检查。
pi@raspberrypi:~ $ nslookup www.baidu.com 192.168.1.1 Server: 192.168.1.1 Address: 192.168.1.1#53 Non-authoritative answer: www.baidu.com canonical name = www.a.shifen.com. Name: www.a.shifen.com Address: 14.215.177.38
- 方法一:使用
- 将dnsmasq的请求发送到smartdns登录路由器,点击
- 启动服务勾选配置页面中的
Enable(启用)
来启动SmartDNS - 注意:
- 如已经安装chinaDNS,建议将chinaDNS的上游配置为SmartDNS。
- SmartDNS默认情况,将53端口的请求转发到SmartDNS的本地端口,由
Redirect
配置选项控制。
大佬,去github安装2个后进去openwrt提示RPC call to uci/get failed with ubus code 6: 没有权限
这个怎么办啊
这个直接在实体机上安装就行了,显示没权限你可以尝试上传到root目录下安装试试
安装了,但没显示有openwrt服务菜单上,是什么原因?
请问smart dns和ros里的dns cache 哪个效率更高呢?
个人觉得配置得当的话是smartdns比较好用