拖拉不拖拉机 發表於 2022-10-12 21:06:00

DNS域名解析服务

<p><strong><span style="background-color: rgba(255, 255, 255, 1); font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">什么是域名?</span></strong></p>
<p><span style="background-color: rgba(255, 255, 255, 1); font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">&nbsp; &nbsp; &nbsp; &nbsp;域名(DomainName),简称域名、网域,是由一串用点分隔的名字组成的Internet上某一台计算机</span><span style="background-color: rgba(255, 255, 255, 1); font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">或计算机组的名称,<strong>用于在数据传输时标识计算机的电子方位。具有独一无二,不可重复的特性</strong>。</span></p>
<p><strong><span style="background-color: rgba(255, 255, 255, 1); font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">域名的关系和组成:</span></strong></p>
<p>&nbsp;<span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">&nbsp; &nbsp; &nbsp;常见域名:www.baidu.com</span><br><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">&nbsp; &nbsp; &nbsp; 完整域名:www.baidu.com<strong>.&nbsp; &nbsp; &nbsp; </strong></span><span style="color: rgba(255, 0, 0, 1); font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">&nbsp;</span><span style="color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></p>
<p><span style="color: rgba(0, 0, 0, 1)"><strong><span style="background-color: rgba(255, 255, 255, 1); font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">域名体系结构:&nbsp;</span></strong></span></p>
<p><span style="font-size: 16px"><span style="background-color: rgba(255, 255, 255, 1); font-family: &quot;Microsoft YaHei&quot;; color: rgba(255, 0, 0, 1)"><span style="color: rgba(0, 0, 0, 1)">把域名空间看做一颗倒置的树;</span></span>在IPV4网络中,<span style="font-family: &quot;Microsoft YaHei&quot;"><strong>全球只有13台根域名服务器</strong></span>,<span style="font-family: &quot;Microsoft YaHei&quot;"><strong>唯一的主根域名服务器部署在美国</strong>,其余12个辅助根域名服务器也都在国外。</span></span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><strong>'.'</strong> 根域,可省略不写。</span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">com:顶级域,由ICANN组织指定和管理。</span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">baidu:级域(注册域) ,<strong>可由·个人或组织申请注册</strong>。</span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">www:三级域(子域),<strong>服务器网站名代表</strong>。</span></p>
<p><img src="https://img2022.cnblogs.com/blog/2999070/202210/2999070-20221012093442503-677827722.png"></p>
<p><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">什么是DNS?</span></strong></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">域名系统(Domain Name System)是互联网的一项服务。域名解析是<strong>把域名指向网站空间IP</strong>,让人们<strong>通过注册的域名可以方便地访问到网站的一种服务</strong>。IP地址是网络上标识站点的数字地址,<strong>为了方便记忆</strong>,采用域名来代替IP地址标识站点地址。域名解析就是<strong>域名到IP地址的转换过程</strong>。域名的解析工作由DNS服务器完成。可以理解为DNS就是翻译官。<strong>DNS端口为53 UDP</strong></span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><strong>正</strong>向解析:<strong>域名 --&gt; IP地址</strong></span><br><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><strong>反</strong>向解析:<strong>IP地址 --&gt; 域名</strong></span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><span style="color: rgba(0, 0, 0, 1)"><strong>DNS查询模式:</strong></span> </span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">递归查询 、 迭代查询</span></p>
<p><span style="color: rgba(0, 0, 0, 1)"><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">安装与配置DNS服务器:</span></strong></span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BIND(Berkeley Internet Name Domain)是一款开源的DNS服务器软件,使用BIND配置DNS服务器一般称为DNS(BIND)服务器。</span></p>
<div>
<table style="height: 211px; float: left; width: 829px" border="0"><caption><span style="color: rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1); font-size: 16px"><strong><span style="font-family: &quot;Microsoft YaHei&quot;">BIND相关rpm包</span></strong></span></caption>
<tbody>
<tr>
<td>
<table style="width: 783px" border="0" align="left">
<tbody>
<tr>
<td style="text-align: center"><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">rpm名称</span></td>
<td style="text-align: center"><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">说明</span></td>



</tr>
<tr>
<td style="text-align: center"><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">bind</span></td>
<td style="text-align: left"><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">配置DNS服务器的主程序包</span></td>



</tr>
<tr>
<td style="text-align: center"><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">bind-chroot</span></td>
<td style="text-align: left"><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">使用BIND运行在监牢目录(/var/named/chroot)中的安全增强工具</span></td>



</tr>
<tr>
<td style="text-align: center"><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">bind-utils</span></td>
<td style="text-align: left"><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">提供DNS测试命令,包括dig、host、nslookup等(系统默认安装)</span></td>



</tr>
<tr>
<td style="text-align: center"><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">bind-libs</span></td>
<td style="text-align: left"><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">域名解析需要的库文件(系统默认安装)</span></td>



</tr>



</tbody>



</table>



</td>
<td><span style="color: rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1)">&nbsp;</span></td>



</tr>



</tbody>



</table>



</div>
<p><span style="color: rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1)">&nbsp;</span></p>
<p><span style="color: rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1)">&nbsp; &nbsp; &nbsp;</span></p>
<p><span style="color: rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1)">&nbsp;</span></p>
<p><span style="color: rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1)">&nbsp;</span></p>
<p><span style="color: rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1)">&nbsp;</span></p>
<p><span style="color: rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1)">&nbsp;</span></p>
<p><span style="color: rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1)">&nbsp;</span></p>
<div>
<table style="height: 215px; float: left; width: 866px" border="0"><caption><span style="color: rgba(0, 0, 0, 1); background-color: rgba(255, 255, 255, 1)"><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">BIND服务器配置文件</span></strong></span></caption>
<tbody>
<tr>
<td><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">文件名称及位置</span></td>
<td><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">作用</span></td>



</tr>
<tr>
<td><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)"><strong>主</strong>配置文件:/etc/named.conf</span></td>
<td><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">设置DNS(BIND)服务器的运行参数</span></td>



</tr>
<tr>
<td><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)"><strong>根域数据库</strong>文件:/var/named/named.ca</span></td>
<td><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">记录了lnternet中的13台根域名服务器的IP地址</span></td>



</tr>
<tr>
<td><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)"><strong>区域</strong>配置文件:/etc/named.rfc1912.zones</span></td>
<td><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">用于声明区域文件</span></td>



</tr>
<tr>
<td><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">区域数据库文件:一般存放在/var/named</span></td>
<td><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 255, 255, 1); color: rgba(0, 0, 0, 1)">保存所管理的DNS数据</span></td>



</tr>



</tbody>



</table>



</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<hr>
<p style="text-align: center"><span style="color: rgba(0, 0, 0, 1); font-size: 14pt"><strong><span style="font-family: &quot;Microsoft YaHei&quot;">DNS---域名解析系统搭建</span></strong></span></p>
<p style="text-align: left"><span style="color: rgba(0, 0, 0, 1); font-size: 14pt"><strong><span style="font-family: &quot;Microsoft YaHei&quot;">server:</span></strong></span></p>
<p><span style="color: rgba(0, 0, 0, 1); background-color: rgba(255, 153, 0, 1); font-size: 16px"><strong><span style="font-family: &quot;Microsoft YaHei&quot;">一、保证两台主机之间的连通性、配置网络、挂载光盘写yum配置文件</span></strong></span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; color: rgba(0, 0, 0, 1); background-color: rgba(255, 153, 0, 1)"><strong>二、安装DNS所需要的包</strong></span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; color: rgba(0, 0, 0, 1)"><strong>yum -y install bind</strong></span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; color: rgba(0, 0, 0, 1); background-color: rgba(255, 153, 0, 1)"><strong>三、配置:主文件、区域文件、正向解析数据文件、反向解析数据文件</strong></span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; color: rgba(0, 0, 0, 1)"><strong>1、主配置文件</strong>&nbsp; &nbsp;</span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp;<strong>/etc/named.conf</strong></span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><span style="color: rgba(255, 0, 0, 1)"><span style="color: rgba(0, 0, 0, 1)"><img src="https://img2023.cnblogs.com/blog/2999070/202301/2999070-20230118192846178-181849097.png"></span></span></span></p>
<p><span style="color: rgba(0, 0, 0, 1); font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><strong>&nbsp;2、区域配置文件&nbsp;</strong> &nbsp; </span></p>
<p><span style="color: rgba(0, 0, 0, 1); font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">&nbsp; &nbsp; &nbsp;<strong> /etc/named.rfc1912.zones</strong></span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">&nbsp; &nbsp; &nbsp; &nbsp;一台DNS服务器可以管理一个或多个区域,一个区域也可以有多台DNS服务器管理,例如:由一台主DNS服务器和多台辅助DNS服务器管理。在DNS服务器中必须先声明所管理的区域,然后在区域中添加资源记录,才能完成域名解析工作。在该文件中声明正向解析区域和反向解析区域。</span></p>
<p><img src="https://img2023.cnblogs.com/blog/2999070/202301/2999070-20230118193726234-160445575.png"></p>
<p><img src="https://img2023.cnblogs.com/blog/2999070/202301/2999070-20230118201609902-964570644.png"></p>
<p><strong><span style="color: rgba(0, 0, 0, 1); font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">3、配置区域数据库文件</span></strong></p>
<p><span style="color: rgba(255, 0, 0, 1); font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><span style="color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp;区域数据库文件: 用来保存一个区域内所有数据(包括主机名和对应的IP地址、刷新间隔和过期时间等)的文件。DNS的区域数据库文件一般保存在/var/named目录下,通常以<span style="color: rgba(255, 0, 0, 1)">.<span style="color: rgba(0, 0, 0, 1)">zone</span></span>作为文件名的后缀。一台DNS服务器可以保存多个区域数据库文件,同一个区域数据库文件也可以存放在多台DNS服务器上。</span></span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;"><span style="font-size: 16px">&nbsp; &nbsp; &nbsp; 在DNS(BIND)服务器的/var/named目录中默认有<span style="color: rgba(0, 0, 0, 1)">named.localhost和named.loopback</span>两个文件。<strong>named.localhost是本地正向区域数据库文件</strong>,用于将名称localhost转换为本机IP地址127.0.0.1,<strong>named.loopback是本地反向区域数据库文件</strong>,用于将本机IP地址127.0.0.1转换为localhost。n<strong>amed.ca:记录了13台根域服务器的位置.</strong></span></span></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;"><span style="font-size: 16px"><strong><img src="https://img2023.cnblogs.com/blog/2999070/202301/2999070-20230118200700447-1418745270.png"></strong></span></span></p>
<p>&nbsp;</p>
<p><span style="color: rgba(255, 0, 0, 1); font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><span style="color: rgba(0, 0, 0, 1)"><strong>1、进入named目录</strong>&nbsp; &nbsp;</span></span></p>
<p><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">cd /var/named</span></strong></p>
<p><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">cp named.localhost zheng</span></strong></p>
<p><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">cp named.loopback fan&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></strong></p>
<p><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">&nbsp;2、配置正向文件</span></strong></p>
<p><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; color: rgba(0, 0, 0, 1)">vim zheng</span></strong></p>
<p><img src="https://img2023.cnblogs.com/blog/2999070/202301/2999070-20230118203252930-1100091965.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">3、配置反向文件</span></strong></p>
<p><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; color: rgba(0, 0, 0, 1)">vim fan</span></strong></p>
<p>&nbsp;<img src="https://img2023.cnblogs.com/blog/2999070/202301/2999070-20230118201119220-667017323.png"></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; background-color: rgba(255, 153, 0, 1)"><strong>四、关闭防火墙、重启服务</strong></span></p>
<p><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; color: rgba(0, 0, 0, 1)">systemctl stop firewalld</span></strong></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><strong><span style="color: rgba(0, 0, 0, 1)">systemctl restart named&nbsp;</span> &nbsp;</strong>&nbsp; &nbsp;</span></p>
<p><span style="font-size: 14pt; font-family: &quot;Microsoft YaHei&quot;"><strong>client 验证:&nbsp; </strong></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>
<p><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px; color: rgba(0, 0, 0, 1); background-color: rgba(255, 153, 0, 1)">一、配置网络</span></strong></p>
<p><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">DNS=服务器IP</span></strong></p>
<p><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px"><span style="color: rgba(255, 0, 0, 1)"><span style="background-color: rgba(255, 153, 0, 1)"><strong><span style="color: rgba(0, 0, 0, 1)">二、用nslookup验证&nbsp;</span></strong></span> &nbsp;</span> &nbsp; </span></p>
<p><strong><span style="font-family: &quot;Microsoft YaHei&quot;; font-size: 16px">yum -y install bind-utils</span></strong></p>
<p><img src="https://img2023.cnblogs.com/blog/2999070/202301/2999070-20230118201414562-918966219.png"></p>
<p>&nbsp;</p><br><br>
来源:https://www.cnblogs.com/lpmp/p/16784061.html
頁: [1]
查看完整版本: DNS域名解析服务