DNS负载均衡


DNS负载均衡

.com的DNS域名服务器是[a-m].gtld-servers.net

获取它的SOA服务器(因为dns缓存查询服务器会缓存结果,如果你直接去查询域名,会每次返回一样的结果)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# dig @m.gtld-servers.net github.com

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.4 <<>> @m.gtld-servers.net github.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23023
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 8, ADDITIONAL: 2
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;github.com. IN A

;; AUTHORITY SECTION:
github.com. 172800 IN NS ns1.p16.dynect.net.
github.com. 172800 IN NS ns3.p16.dynect.net.
github.com. 172800 IN NS ns2.p16.dynect.net.
github.com. 172800 IN NS ns4.p16.dynect.net.
github.com. 172800 IN NS ns-520.awsdns-01.net.
github.com. 172800 IN NS ns-421.awsdns-52.com.
github.com. 172800 IN NS ns-1707.awsdns-21.co.uk.
github.com. 172800 IN NS ns-1283.awsdns-32.org.

;; ADDITIONAL SECTION:
ns-421.awsdns-52.com. 172800 IN A 205.251.193.165

获取了8个SOA服务器 选一个来问问github.com对应的记录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# dig @ns-520.awsdns-01.net github.com

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.4 <<>> @ns-520.awsdns-01.net github.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41408
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 8, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;github.com. IN A

;; ANSWER SECTION:
github.com. 60 IN A 13.250.177.223

利用dns实现了负载均衡,访问会到达不同的ip地址

  • 支持负载均衡的DNS服务商
1
2
3
4
AWS Route 53
NSONE
Dyn
dnspod

DNS可以做故障转移,也可以按地区解析等等