通知 爱刷机 路由器教程 →→《值得买》 ←←

自用SmartDNS配置分享SmartDNS配置方法

2024-09-22
0评论
/
阅读
爱搜啊

SmartDNS简介

SmartDNS是一种智能DNS解析工具,它通过预先解析和缓存域名请求,提升用户访问速度和体验。通过合理配置SmartDNS,用户可以享受到更快速、更稳定的上网体验。

自用SmartDNS配置分享


以下是我个人的SmartDNS配置,经过多次测试,效果良好:



2023-03-17补充:


考虑到同时开预读取和过期缓存,预读取的时间是12小时定时,大家可以考虑只开prefetch-domain或者serve-expired其中一个,如果两个同时开的话,请加serve-expired-prefetch-time参数指定一下过期缓存预读取的时间,我觉得12小时太长了,可能效果不是很好。


SmartDNS争议很大,mosdns、adg等我都用过,也进行了各种套娃,尝试了各种组合后感觉效果还是单用smartdns的好,最终选择了单用smartdns。


这里不做任何讨论,只是分享我个人自用的稳定配置,在电信、移动的网络上使用都感觉还行。


话不多说上配置↓↓↓

#绑定端口
bind [::]:6353

#指定缓存大小
cache-size 32768

#开启预取
prefetch-domain yes

#开启过期缓存
serve-expired yes

#禁用ipv6
force-AAAA-SOA yes

#禁用 SOA 65
force-qtype-SOA 65

#设置日志文件
log-level debug
log-file smartdns.log
log-size 64k
log-num 1

#引入中国域名列表
conf-file /etc/smartdns/cn.conf

#指定上游服务器解析DOH,搭配下面的nameserver避免各方打架,不参与默认解析
server 8.8.8.8 -group google -exclude-default-group
server 8.8.4.4 -group google -exclude-default-group
server 1.1.1.1 -group cloudflare -exclude-default-group
server 1.0.0.1 -group cloudflare -exclude-default-group
server 9.9.9.9 -group quad9 -exclude-default-group
server 208.67.222.222 -group opendns -exclude-default-group
server 223.6.6.6 -group alidns -exclude-default-group
server 223.5.5.5 -group alidns -exclude-default-group
server 119.29.29.29 -group dnspod -exclude-default-group
server 119.28.28.28 -group dnspod -exclude-default-group
server 101.101.101.101 -group twnic -exclude-default-group

#CN组服务器,用于解析中国域名列表,不参与默认解析,防止泄露
server-https https://dns.alidns.com/dns-query -group cn -exclude-default-group
server-https https://doh.pub/dns-query -group cn -exclude-default-group
server 114.114.114.114 -group cn -exclude-default-group
server 1.2.4.8 -group cn -exclude-default-group

#默认组
server-https https://dns.google/dns-query
server-https https://dns.quad9.net/dns-query
server-https https://doh.opendns.com/dns-query
server-https https://cloudflare-dns.com/dns-query
server-https https://dns.twnic.tw/dns-query

#指定上游解析DOH服务器
nameserver /alidns.com/alidns
nameserver /doh.pub/dnspod
nameserver /dns.google/google
nameserver /quad9.net/quad9
nameserver /opendns.com/opendns
nameserver /cloudflare-dns.com/cloudflare
nameserver /twnic.tw/twnic

关键配置项解释

缓存大小 (cache-size):设置DNS缓存的大小,适当增大可以提升性能。

预取 (prefetch-domain):开启域名预取功能,提前解析常用域名,加快后续访问速度。

过期缓存 (serve-expired):即使缓存过期,仍然可以提供旧数据,减少请求延迟。

日志配置:记录日志以便调试和监控DNS解析过程。


PS:中国域名列表是使用了Loyalsoldier/“师夷长技以制夷”-rules-dat的直连域名列表 direct-list、Apple 在中国大路可直连的域名列表 apple-cn、Google 在中国大路可直连的域名列表 google-cn三个列表进行合并生成,这里也一并给出更新脚本:

#删除旧文件
rm /etc/smartdns/cn.conf

#下载三个最新列表合并到cn.conf
curl  "https://cdn.jsdelivr.net/gh/Loyalsoldier/“师夷长技以制夷”-rules-dat@release/direct-list.txt"  >> /etc/smartdns/cn.conf
curl  "https://cdn.jsdelivr.net/gh/Loyalsoldier/“师夷长技以制夷”-rules-dat@release/apple-cn.txt"    >> /etc/smartdns/cn.conf
curl  "https://cdn.jsdelivr.net/gh/Loyalsoldier/“师夷长技以制夷”-rules-dat@release/google-cn.txt"   >> /etc/smartdns/cn.conf

#去除full regexp并指定cn组解析
sed "s/^full://g;/^regexp:.*$/d;s/^/nameserver \//g;s/$/\/cn/g" -i /etc/smartdns/cn.conf

点击链接加入群聊三群:751529538

点击链接加入群聊二群:376877156

点击链接加入群聊【路由器交流群:622891808已满】

本站附件分享,如果附件失效,可以去找找看

诚通网盘附件百度网盘附件


饿了么红包

饿了么红包

标签: SmartDNS 配置
于2024-09-22发布