昨天在通过公司的系统配置公网域名,顺带花点时间研究了 域名体系的运作;
要点如下:
1. full qualified domain name FQDN,如 www.baidu.com; 公网(互联网)上的FQDN是一种资源,在全球的分布式DNS系统中需要 存储空间和基于UDP 的DNS查询服务 等资源来保持域名可用:即通过域名 找到IP(v4 或v6);
2. 注册域名 即为 在 全球分布式 DNS系统中增加了一些纪录(A纪录,或者CNAME,NS纪录等)目的是两个:一是在 interNIC 声明 拥有一个域名所有权如 baidu.com; 二是 建立 域名到 IP地址的 映射(可以是多个IP地址,DNS轮询的负载均衡)
3. 全球分布式 DNS系统 分为 4级ROOT(13个server), TOP LEVEL DOMAIN(13个server),SECOND LEVEL DOMAIN,代理商/企业的ns server;
4.DNS也可以负载均衡,不过缺点也很明显;
5.从高可用的web服务角度来看, 轻量级 入口loader balancer的 实践一般 用 lvs+keepalived或nginx+keepalived 提供VIP(virtualIP);整个集群服务高可用 用 heartbeat(如mysql集群高可用)
6. 域名系统常用命令: hostname, nslookup, dig ;
7..以 www.taoba.com域名为例子,可用看到最终通过 A纪录 确定的 IP地址是:140.205.16.92
dig +trace www.taobao.com
; <<>> DiG 9.8.3-P1 <<>> +trace www.taobao.com
;; global options: +cmd
.11751INNSe.root-servers.net.
.11751INNSg.root-servers.net.
.11751INNSb.root-servers.net.
.11751INNSm.root-servers.net.
.11751INNSf.root-servers.net.
.11751INNSh.root-servers.net.
.11751INNSk.root-servers.net.
.11751INNSi.root-servers.net.
.11751INNSj.root-servers.net.
.11751INNSd.root-servers.net.
.11751INNSl.root-servers.net.
.11751INNSc.root-servers.net.
.11751INNSa.root-servers.net.
;; Received 505 bytes from 10.65.1.1#53(10.65.1.1) in 31 ms
com.172800INNSa.gtld-servers.net.
com.172800INNSb.gtld-servers.net.
com.172800INNSc.gtld-servers.net.
com.172800INNSd.gtld-servers.net.
com.172800INNSe.gtld-servers.net.
com.172800INNSf.gtld-servers.net.
com.172800INNSg.gtld-servers.net.
com.172800INNSh.gtld-servers.net.
com.172800INNSi.gtld-servers.net.
com.172800INNSj.gtld-servers.net.
com.172800INNSk.gtld-servers.net.
com.172800INNSl.gtld-servers.net.
com.172800INNSm.gtld-servers.net.
;; Received 492 bytes from 199.7.83.42#53(199.7.83.42) in 328 ms
taobao.com.172800INNSns4.taobao.com.
taobao.com.172800INNSns5.taobao.com.
taobao.com.172800INNSns6.taobao.com.
taobao.com.172800INNSns7.taobao.com.
;; Received 232 bytes from 192.31.80.30#53(192.31.80.30) in 91 ms
www.taobao.com.600INCNAMEwww.taobao.com.danuoyi.tbcache.com.
danuoyi.tbcache.com.10800INNSdanuoyins9.tbcache.com.
danuoyi.tbcache.com.10800INNSdanuoyins8.tbcache.com.
danuoyi.tbcache.com.10800INNSdanuoyins4.tbcache.com.
danuoyi.tbcache.com.10800INNSdanuoyins5.tbcache.com.
danuoyi.tbcache.com.10800INNSdanuoyins6.tbcache.com.
danuoyi.tbcache.com.10800INNSdanuoyins7.tbcache.com.
;; Received 323 bytes from 140.205.2.188#53(140.205.2.188) in 7 ms
dig www.taobao.com.danuoyi.tbcache.com
; <<>> DiG 9.8.3-P1 <<>> www.taobao.com.danuoyi.tbcache.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64897
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.taobao.com.danuoyi.tbcache.com. INA
;; ANSWER SECTION:
www.taobao.com.danuoyi.tbcache.com. 45 IN A140.205.16.92
;; Query time: 1 msec
;; SERVER: 10.65.1.1#53(10.65.1.1)
;; WHEN: Mon Jul 17 10:29:50 2017
;; MSG SIZErcvd: 68
8.域名系统还可以支持 PTR 反向查询 ip地址对应的域名;
dig -x 140.205.16.92
; <<>> DiG 9.8.3-P1 <<>> -x 140.205.16.92
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 2957
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;92.16.205.140.in-addr.arpa.INPTR
;; AUTHORITY SECTION:
205.140.in-addr.arpa.300 IN SOA rdns1.alidns.com. dnsmgr.alibaba-inc.com. 2015012442 1800 600 1814400 300
;; Query time: 24 msec
;; SERVER: 10.65.1.1#53(10.65.1.1)
;; WHEN: Mon Jul 17 10:31:16 2017
;; MSG SIZErcvd: 115