国内外公共 DNS调研

国内外公共 DNS调研

结论

国内可以在以下DNS选择:114DNS、阿里DNS。(阿里请联系我,给我广告费^_^)

国外可以在以下DNS选择:谷歌DNS、1.1.1.1 DNS、Cisco Umbrella DNS。

国内DNS对比

DNS服务

提供商

地址

优势

缺点

其他

114DNS

中国电信

114.114.114.114

节点:国内拥有1000+节点。在中国用户量第一。

阿里DNS

阿里

223.5.5.5223.6.6.6(备用)

节点: 国内每个省都有节点。海外26个国家拥有节点。

官网:https://www.alidns.com/

DNSpod

腾讯

119.29.29.29

节点: 免费版>8 智能解析:如同运营商访问

官网:https://www.dnspod.cn/products/publicdns

oneDNS

北京微步在线科技

117.50.11.1152.80.66.66

节点: 80+ 华北、华中、华南都有 商业版:攻防演练、防止DNS污染。(来自客服)

官网:https://www.onedns.net/

百度DNS

百度

180.76.76.76

网站老旧

官网:https://dudns.baidu.com/

联通DNS

联通

210.22.70.3(上海)

各省份的DNS地址不一样

sDNS

中国互联网络信息中心

1.2.4.8 210.2.4.8

-

客服电话是空号、或无人接听

官网:https://www.sdns.cn/

中科大DNS

中科大

202.141.162.123:5353 202.141.178.13:5353

可能会更改ip地址

清华DNS

清华

101.6.6.6:5353

节点数:1

DNS派

360

电信:101.226.4.6 联通:123.125.81.6 移动:101.226.4.6 铁通:101.226.4.6

就近解析

网站老旧

官网:http://www.dnspai.com/public.html

国外DNS对比

主要数据来源:https://www.dnsperf.com/#!dns-resolvers

DNS服务

提供方

地址

优势

缺点

官网

谷歌DNS

谷歌

8.8.8.8 8.8.4.4

解析速度一流。 稳定性一流。

https://developers.google.com/speed/public-dns?hl=zh-cn

1.1.1.1 DNS

CloudFlare

1.1.1.1 1.0.0.1

解析速度第一。 稳定性第一。(自2022-05到2023-05)

官网:https://1.1.1.1/

G-Core DNS

G-Core

95.85.95.85 2.56.220.2

解析速度一流,但不在前列。 稳定性一流。

官网:https://gcore.com/public-dns

Cisco Umbrella DNS

思科

208.67.222.222 208.67.220.220

解析速度一流。 稳定性一流。

官网: https://umbrella.cisco.com/ https://docs.umbrella.com/deployment-umbrella/docs/point-your-dns-to-cisco

NextDNS

NextDNS

-

解析速度一流。 稳定性一流。

免费版限制300,000 次查询/月

官网:https://nextdns.io/zh

Quad9 DNS

Quad9

9.9.9.9 149.112.112.112

解析速度一流。 稳定性一流。

中国只有香港和台湾有节点

官网:https://www.quad9.net/

测试

结论:

国内只有阿里比电信114强,其他的甚至会有拉跨的现象。

国外可以选择CloudFlare、思科。

为什么要测试?

实践是检验真理的唯一标准,理论与上线之间必须要有测试。

公共DNS是为公众服务的,倾向于全局最优。而我们需要局部最优。(对自己来说是最优)

数据驱动。

测试脚本-得到各分位延迟.go:

package main

import (

"errors"

"fmt"

"github.com/miekg/dns"

"sort"

"sync"

"time"

)

///////////////////////////////////////////////////////////////////////////

// 代码作用:解析域名列表,得到平均延迟、各分位延迟

// 版本:v0.1

// 最近一次更新时间:2023年5月22日

///////////////////////////////////////////////////////////////////////////

type DnsProbe struct {

DomainList []string

Server string

Concurrency int

}

// 检查域名A记录是否正常解析

func checkDomainA(domain string, dnsServer string) (error, time.Duration) {

c := dns.Client{}

c.ReadTimeout = 3000 * time.Millisecond

m := dns.Msg{}

m.SetQuestion(domain, dns.TypeA)

r, rtt, err := c.Exchange(&m, dnsServer)

if err != nil {

return err, rtt

}

// 从返回结果中得到A记录

for _, ans := range r.Answer {

_, ok := ans.(*dns.A)

if ok {

return nil, rtt

}

}

return errors.New("查不到A记录"), 0

}

// 解析所有域名

func (d DnsProbe) CheckDomainList() {

var errCount = 0

var latencySum float64 = 0

var latencys []float64

var wg sync.WaitGroup

wg.Add(len(d.DomainList))

var lockErr sync.Mutex

var lockLatencySum sync.Mutex

countGoroutine := make(chan int, d.Concurrency)

for _, domain := range d.DomainList {

countGoroutine <- 1

go func(domain string) {

defer wg.Done()

// 主要逻辑

err, rtt := checkDomainA(domain, d.Server)

if err != nil {

lockErr.Lock()

defer lockErr.Unlock()

fmt.Printf("[debug] err:%s\n", domain+" "+err.Error())

errCount++

} else {

lockLatencySum.Lock()

defer lockLatencySum.Unlock()

latency := float64(rtt.Microseconds()) / float64(1000)

latencySum += latency

latencys = append(latencys, latency)

}

<-countGoroutine

}(domain)

}

wg.Wait()

sum := len(d.DomainList)

countSuccess := sum - errCount

fmt.Printf("域名总数:%d\n", len(d.DomainList))

if errCount > 0 {

fmt.Printf("成功数:%d\n", countSuccess)

fmt.Printf("失败数:%d\n", errCount)

}

if countSuccess == 0 {

return

}

fmt.Printf("平均延迟:%.4f\n", latencySum/float64(countSuccess))

//计算分位延迟

sort.Float64s(latencys)

index99 := int(0.99 * float64(len(latencys)-1))

index95 := int(0.95 * float64(len(latencys)-1))

index90 := int(0.90 * float64(len(latencys)-1))

var tempSum float64

i := 0

// 90分位

for ; i <= index90; i++ {

tempSum += latencys[i]

}

fmt.Printf("90分位平均/最大延迟:%.2f %.2f\n", tempSum/float64(index90+1), latencys[index90])

// 95分位

for ; i <= index95; i++ {

tempSum += latencys[i]

}

fmt.Printf("95分位平均/最大延迟:%.2f %.2f\n", tempSum/float64(index95+1), latencys[index95])

//99 分位

for ; i <= index99; i++ {

tempSum += latencys[i]

}

fmt.Printf("99分位平均/最大延迟:%.2f %.2f\n", tempSum/float64(index99+1), latencys[index99])

}

func main() {

domainList := []string{"baidu.com.", "taobao.com."}

probe := DnsProbe{

DomainList: domainList,

Server: "10.191.112.3:53",

Concurrency: 5,

}

probe.CheckDomainList()

}

114.114.114.114测试结果:(电信)

域名总数:1174

成功数:1140

失败数:34

平均延迟:27.9103

90分位平均/最大延迟:19.65 23.58

95分位平均/最大延迟:20.18 40.50

99分位平均/最大延迟:22.82 210.91

223.5.5.5测试结果:(阿里)

域名总数:1174

成功数:1143

失败数:31

平均延迟:14.6767

90分位平均/最大延迟:8.37 11.11

95分位平均/最大延迟:8.57 13.96

99分位平均/最大延迟:9.85 85.91

119.29.29.29测试结果:(腾讯)

域名总数:1174

成功数:1134

失败数:40

平均延迟:56.8179

90分位平均/最大延迟:28.09 143.87

95分位平均/最大延迟:36.87 238.82

99分位平均/最大延迟:49.29 592.15

117.50.11.11测试结果:(北京微步)

域名总数:1174

成功数:1128

失败数:46

平均延迟:166.1405

90分位平均/最大延迟:73.53 429.60

95分位平均/最大延迟:102.53 717.20

99分位平均/最大延迟:143.09 1888.25

8.8.8.8测试结果:(谷歌)

域名总数:1174

成功数:1145

失败数:29

平均延迟:294.6463

90分位平均/最大延迟:271.93 366.86

95分位平均/最大延迟:276.98 371.25

99分位平均/最大延迟:284.67 1091.67

1.1.1.1测试结果:(CloudFlare)

域名总数:1174

成功数:1145

失败数:29

平均延迟:178.7482

90分位平均/最大延迟:136.31 336.56

95分位平均/最大延迟:148.73 482.76

99分位平均/最大延迟:166.93 821.59

95.85.95.85测试结果:(G-Core)

域名总数:1174

成功数:1111

失败数:63

平均延迟:527.6431

90分位平均/最大延迟:375.50 1138.58

95分位平均/最大延迟:429.46 1990.93

99分位平均/最大延迟:502.98 2636.41

208.67.222.222测试结果:(思科)

域名总数:1174

成功数:1147

失败数:27

平均延迟:179.5852

90分位平均/最大延迟:142.50 222.05

95分位平均/最大延迟:149.00 318.45

99分位平均/最大延迟:162.16 981.61

9.9.9.9测试结果:(Quad9)

域名总数:1174

成功数:1140

失败数:34

平均延迟:199.7471

90分位平均/最大延迟:140.72 351.70

95分位平均/最大延迟:154.14 483.79

99分位平均/最大延迟:179.46 1865.28

参考文档

http://www.evianbaike.com/article/94186.html

《免费公共DNS服务器大全》https://cloud.tencent.com/developer/article/2102140

《腾讯DNS》https://www.detechn.com/post/48.html

公共DNS

https://www.detechn.com/dns.html

《整理一些常用的DNS》http://www.taodudu.cc/news/show-3637897.html?action=onClick

《国内无污染DNS分享》http://www.sankedan.com/detail/9/720.html?ivk_sa=1024320u

《百度百科-DNSpod》https://baike.baidu.com/item/DNSPod/5669555?fr=aladdin

《五大国内云主机DNS云解析服务对比分析》http://yiluxb.cn/post/612.html

国外DNS服务对比:https://www.dnsperf.com/#!dns-resolvers

《什么是谷歌DNS》https://www.whatismyip.com/google-dns/

《DNS 1.1.1.1——不仅仅是速度第一》https://zhuanlan.zhihu.com/p/135319565

《DNS 解析器性能比较:Google、CloudFlare、Quad9》https://baijiahao.baidu.com/s?id=1660853235054593805&wfr=spider&for=pc

🎨 相关创意作品

被人打了,打人者跑了,派出所找不到人,怎么处理
女性正常腰围对照表
bst365app

女性正常腰围对照表

📅 07-09 👁️ 5414
拼多多和萌店哪个好?有什么区别?
完美体育365

拼多多和萌店哪个好?有什么区别?

📅 08-12 👁️ 3743