Centos7 DNS Domain Name Service (theory + experiment Detailed)

DNS server common concept

One. DNS Service Overview:

DNS (Domain Name System-- Domain Name System), has a very important role in the TCP / IP network, can provide resolution services domain names and IP addresses.

DNS is a distributed database, hierarchical naming system logical structure, as an inverted tree, the logical tree structure called the domain name space, due to the division of the DNS name space, so that the agencies can use your own domain name space created DNS information.

Note: DNS domain name space, the maximum depth of the tree is not more than 127 layers, each node in the tree can store up to 63 characters.


two. Some nouns explanation:

1. The domain and domain name

Each node of the tree represents a DNS domain. Through these nodes, the entire domain name space divided into a hierarchy.

QQ picture 20190901113122.png

The domain name space for each domain, were represented by the domain name.

Domain : usually consists of a fully qualified domain name (FQDN) can be accurately identified .FQDN shows its position relative to the root DNS domain, i.e. the node to the root of a complete presentation of DNS using reverse are written to the root node, and each node with "." separated for the DNS domain google, its fully qualified domain name (FQDN) for the google.com.

For example, google subdomain com domain, which represents Google.com method, and the subdomain www google domain, it can be expressed using www.google.com.

Note: In general, FQDN strict naming restrictions, the length can not exceed 256 bytes, allows only characters az, 0-9, AZ and minus (-) number of points allowed only between domain name signs (eg. (.) the end of "google.com") or FQDN of use.

Domain names are case-sensitive.

From the top level to the lower layer, it can be divided into: a root domain, top-level domain, two domains, subdomains.

Top-level Internet domain name space is the root domain (root), which records important information on the Internet DNS, Internet domain name registered by the management authority, the agency assigned responsibility for the management of the various parts of the domain name space to connect to the Internet organizations.

. "" There are 13 global root (root) server

DNS 根域下面是顶级域,也由Internet 域名注册授权机构管理.共有3 种类型的顶级域.

组织域:采用3 个字符的代号,表示DNS 域中所包含的组织的主要功能或活动.比如com 为商业机构组织,edu 为教育机构组织,gov 为政府机构组织,mil 为军事机构组织,net 为网络机构组织,org 为非营利机构组织,int 为国际机构组织.

地址域:采用两个字符的国家或地区代号.如cn 为中国,kr 为韩国,us 为美国.

反向域:这是个特殊域,名字为in-addr.arpa,用于将IP 地址映射到名字(反向查询).

对于顶级域的下级域,Internet 域名注册授权机构授权给Internet 的各种组织.当一个组织获得了对域名空间某一部分的授权后,该组织就负责命名所分配的域及其子域,包括域中的计算机和其他设备,并管理分配域中主机名与IP 地址的映射信息.

2、区(Zone)

区是DNS 名称空间的一部分,其包含了一组存储在DNS 服务器上的资源记录.

使用区的概念,DNS 服务器回答关于自己区中主机的查询,每个区都有自己的授权服务器.


三.主域名服务器与辅助域名服务器

当区的辅助服务器启动时,它与该区的主控服务器进行连接并启动一次区传输,区辅助服务器定期与区主控服务器通信,查看区数据是否改变.如果改变了,它就启动一次数据更新传输.每个区必须有主服务器,另外每个区至少要有一台辅助服务器,否则如果该区的主服务器崩溃了,就无法解析该区的名称.

辅助服务器的优点:

1)容错能力

配置辅助服务器后,在该区主服务器崩溃的情况下,客户机仍能解析该区的名称.一般把区的主服务器和区的辅助服务器安装在不同子网上,这样如果到一个子网的连接中断,DNS 客户机还能直接查询另一个子网上的名称服务器.

2)减少广域链路的通信量

如果某个区在远程有大量客户机,用户就可以在远程添加该区的辅助服务器,并把远程的客户机配置成先查询这些服务器,这样就能防止远程客户机通过慢速链路通信来进行DNS 查询.

3)减轻主服务器的负载

辅助服务器能回答该区的查询,从而减少该区主服务器必须回答的查询数.


四.DNS 相关概念

(1)DNS 服务器

运行DNS 服务器程序的计算机,储存DNS 数据库信息.DNS 服务器会尝试解析客户机的查询请求.

在解答查询时,如果DNS 服务器能提供所请求的信息,就直接回应解析结果,如果该DNS 服务器没有相应的域名信息,则为客户机提供另一个能帮助解析查询的服务器地址,如果以上两种方法均失败,则回应客户机没有所请求的信息或请求的信息不存在.

(2)DNS 缓存

DNS 服务器在解析客户机请求时,如果本地没有该DNS 信息,则可以会询问其他DNS 服务器,当其他域名服务器返回查询结果时,该DNS 服务器会将结果记录在本地的缓存中,成为DNS 缓存.当下一次客户机提交相同请求时,DNS 服务器能够直接使用缓存中的DNS 信息进行解析.

(3)DNS查询过程:

看一个DNS查询过程:

通过8个步骤的解析域名,但实际应用中,通常这个过程是非常迅速的

 

<1> 客户机提交域名解析请求,并将该请求发送给本地的域名服务器.

<2> 当本地的域名服务器收到请求后,就先查询本地的缓存.

如果有查询的DNS 信息记录,则直接返回查询的结果.

如果没有该记录,本地域名服务器就把请求发给根域名服务器.

<3> 根域名服务器再返回给本地域名服务器一个所查询域的顶级域名服务器的地址.

<4> 本地服务器再向返回的域名服务器发送请求.

<5> 接收到该查询请求的域名服务器查询其缓存和记录,如果有相关信息则返回客户机查询结果,否则通知客户机下级的域名服务器的地址.

<6> 本地域名服务器将查询请求发送给返回的DNS 服务器.

<7> 域名服务器返回本地服务器查询结果(如果该域名服务器不包含查询的DNS 信息,查询过程将重复<6>、<7>步骤,直到返回解析信息或解析失败的回应).

<8> 本地域名服务器将返回的结果保存到缓存,并且将结果返回给客户机.

QQ picture 20190901114001.png

 

五.两种查询方式:

(1)递归查询

递归查询是一种DNS 服务器的查询模式,在该模式下DNS 服务器接收到客户机请求,必须使用一个准确的查询结果回复客户机.如果DNS 服务器本地没有存储查询DNS 信息,那么该服务器会询问其他服务器,并将返回的查询结果提交给客户机.

(2)迭代查询

DNS 服务器另外一种查询方式为迭代查询,当客户机发送查询请求时,DNS 服务器并不直接回复查询结果,而是告诉客户机另一台DNS 服务器地址,客户机再向这台DNS 服务器提交请求,依次循环直到返回查询的结果为止.


六.正向解析与反向解析

1)正向解析

正向解析是指域名到IP 地址的解析过程.

2)反向解析

反向解析是从IP 地址到域名的解析过程.反向解析的作用为服务器的身份验证



DNS服务的配置文件

一.主配置文件

/etc/named.conf

功能:控制系统全局


二.区域配置文件

/etc/named.rfc1912.zones

功能:控制具体单个区域


三.区域数据配置文件

/etc/named/named.localhost

功能:区域信息



DNS服务正向解析搭建

1.使用yum install bind -y  安装bind包

image.png


2.修改全局配置文件 vim /etc/named.conf

image.png


3.修改区域配置文件  vim /etc/named.rfc1912.conf

image.png




4.复制区域数据文件模板

image.png



5.修改区域数据文件  vim /etc/named/kgc.com.zone

image.png



6.关闭防火墙,开启服务

image.png


7.修改dns配置文件

image.png


8.用host 域名  进行解析验证

image.png



DNS反向解析配置过程

1.修改区域配置文件 vim /etc/named.rfc1912.zones

image.png


2.复制区域数据文件模板 

image.png



3.修改区域数据文件vim /etc/named/yun.com.local

image.png


4.重启服务 systemctl restart named

image.png


5.验证 host

image.png





DNS服务器主从同步

1. re-open a virtual machine as a secondary server, and turn off the firewall, install bind

image.png


image.png




2. Modify the global configuration file vim /etc/named.conf

image.png




3. Modify zone configuration file vim /etc/named.rfc1912.zones

image.png



4. Switch to the primary server to modify the region profile vim /etc/named.rfc1912.zones

image.png




5. Restart the primary server service

image.png


6. Modify from the dns server configuration file, and open service

image.png


7. Verify

image.png


From the server has a considerable analytic function with the primary server





Guess you like

Origin blog.51cto.com/14469918/2434504