DNS介绍

DNS基础篇

DNS介绍

DNS(Domain Network System):域名解析系统,目的是使互联网用户和设备用易于记忆和辨别的域名名字来访问网站,由DNS系统来完成域名到网络层面IP地址的转化过程.该标准定义在RFC1035.

比如:百度服务IP地址是:39.156.69.79,淘宝服务IP: 140.205.94.189,这种网络IP地址很不方便记忆和识别,如果使用baidu.com 或者 taobao.com,则很方便记忆和识别,这个转化就由DNS系统完成。

DNS系统是目前互联网的基础服务,如果DNS服务出现问题,会造成网络的中断,服务的不可访问等等严重后果.

本文将对DNS进行深入的讲解和分析.

DNS服务过程

术语说明:
ISP: 网络服务商,比如:中国电信、中国联通
TLD: 顶级域名,比如:org, com等等,登记域名都由大商来负责管理和注册,比如: VeriSign

以访问www.unknown.com为例

  1. 当你在浏览器里面输入www.unkonwn.com,浏览器首先去查询ISP DNS服务器或者系统配置的DNS服务器(专业术语叫做: Recursive Resolver).如果访问的DNS服务器有缓存的当前域名信息,则直接返回对应的ip信息,浏览器可以发送服务请求了.
  2. 如果上述DNS服务器没有缓存,则DNS服务器向Root Server查询请求,Root Server不包含特定域名的IP地址信息,它仅包含TLD(Top Level Domain)的信息,比如: .com,.org等等, Root Server根据当前查询域名的信息,提取TLD, 然后返回TLD Servers的信息.
  3. DNS服务器再次向TLD域名服务器发起查询请求,TLD服务器根据查询域名的信息,返回对应信息保存的Authoritative Name Servers.
  4. DNS服务器请求Authoritative Name Servers,返回对应的域名IP信息.
  5. DNS服务器返回域名对应的IP给浏览器.
  6. 浏览器根据查询的IP查询应用服务器.

具体流程可以参考下图:
在这里插入图片描述

Root Servers
Root Server的总数量只有13个,这个是由于早期的历史限制,但是IP包限制长度512bit, 每个ip地址32bit,13个root servers地址消耗了416bit, 剩余的96bit预留给协议用. 同时早期每个Root Server由一个机器负责,在目前的网络体量下肯定是不可能胜任的,目前使用机器集群,集群见使用anycast routing机制.13个root servers可以查看: https://www.iana.org/domains/root/servers

DNS服务商
有些情况下各个电信运营商的域名解析服务器存在问题,我们可以使用其他第三方提供的解析服务,比如:
114DNS 114.114.114.114 114.114.115.115
阿里DNS 223.5.5.5 223.6.6.6
百度DNS 180.76.76.76
谷歌DNS 8.8.8.8
OpenDNS 208.67.220.220

查看域名信息

Linux环境下可以通过dig命令来完成,当然你也可以通过网页服务来查询.

[root@localhost ~]# dig baidu.com
...省略
;; QUESTION SECTION:
;baidu.com.			IN	A

;; ANSWER SECTION:
baidu.com.		5	IN	A	39.156.69.79
baidu.com.		5	IN	A	220.181.38.148

;; Query time: 25 msec
;; SERVER: 192.168.119.2#53(192.168.119.2)
;; WHEN: Thu Jan 16 15:44:33 CST 2020
;; MSG SIZE  rcvd: 59

在这里插入图片描述

那么上面步骤我们知道域名是怎么最终解析到对应的IP地址,但是这个信息又是怎么来的呢?谁提供的呢?

域名购买

域名的购买其实和域名的解析的过程是反向的,通过TLD域名的管理机构会委托下级机构机构进行域名的注册、信息维护、解析等.
我们通常在万网或者其他域名服务商购买域名,这些服务商本身要注意并不是域名管理机构,他们负责将注册信息同步给管理机构,中间赚钱服务费用而已,整个注册信息流如下:
在这里插入图片描述
具体的注册流程依服务商不同有一定的差异,比如:
阿里云: https://wanwang.aliyun.com/
腾讯云: https://dnspod.cloud.tencent.com/
百度云: https://cloud.baidu.com/product/bcd.html

查询域名注册信息

域名信息可以通过whois服务来查询,linux环境用whois命令或者网页服务

[root@localhost ~]# whois jiangjianedu.cn
Domain Name: jiangjianedu.cn
ROID: 20180305s10001s99279448-cn
Domain Status: ok
Registrant ID: hc2623114695713
Registrant: 姜健
Registrant Contact Email: 1264545970@qq.com
Sponsoring Registrar: 阿里云计算有限公司(万网)
Name Server: dns21.hichina.com
Name Server: dns22.hichina.com
Registration Time: 2018-03-05 13:42:02
Expiration Time: 2020-03-05 13:42:02
DNSSEC: unsigned
[root@localhost ~]#

在这里插入图片描述

whois默认是查询whois.networksolutions.com的域名信息数据库的数据

DNS进阶篇

DNS协议

服务端口:53
使用协议: UDP

DNS记录类型:

类型全称说明
AAddress Mapping recordalso known as a DNS host record, stores a hostname and its corresponding IPv4 address.
AAAAIP Version 6 Address recordstores a hostname and its corresponding IPv6 address.
CNAMECanonical Name recordcan be used to alias a hostname to another hostname. When a DNS client requests a record that contains a CNAME, which points to another hostname, the DNS resolution process is repeated with the new hostname.
MXMail exchanger record—specifies an SMTP email server for the domain, used to route outgoing emails to an email server.
NSName Server recordspecifies that a DNS Zone, such as “example.com” is delegated to a specific Authoritative Name Server, and provides the address of the name server.
PTRReverse-lookup Pointer recordsallows a DNS resolver to provide an IP address and receive a hostname (reverse DNS lookup).
CERTCertificate recordstores encryption certificates—PKIX, SPKI, PGP, and so on.
SRVService Locationa service location record, like MX but for other communication protocols.
TXTText Recordtypically carries machine-readable data such as opportunistic encryption, sender policy framework, DKIM, DMARC, etc.
SOAStart of Authoritythis record appears at the beginning of a DNS zone file, and indicates the Authoritative Name Server for the current DNS zone, contact details for the domain administrator, domain serial number, and information on how frequently DNS information for this zone should be refreshed.

安装dns服务器

https://www.itzgeek.com/how-tos/linux/centos-how-tos/configure-dns-bind-server-on-centos-7-rhel-7.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值