DNS服务的搭建

为openlab搭建web网站,要求基于域名www.openlab.com可以访问网站信息。
自己搭建dns master、slave服务实现解析。

[root@yy ~]# systemctl stop firewalld
[root@yy ~]# setenforce 0
[root@yy ~]# mount /dev/sr0 /mnt
[root@yy ~]# yum install bind -y
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository bash is listed more than once in the configuration
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
bash                                                    | 4.1 kB     00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 bind.x86_64.32.9.9.4-29.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===============================================================================
 Package       架构            版本                        源             大小
===============================================================================
正在安装:
 bind          x86_64          32:9.9.4-29.el7             bash          1.8 M

事务概要
===============================================================================
安装  1 软件包

总下载量:1.8 M
安装大小:4.3 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 32:bind-9.9.4-29.el7.x86_64                                1/1 
  验证中      : 32:bind-9.9.4-29.el7.x86_64                                1/1 

已安装:
  bind.x86_64 32:9.9.4-29.el7                                                  

完毕!
[root@yy ~]# yum install httpd

配置文件

options {
        listen-on port 53 { 192.168.159.129; };
        directory "/var/named";
};
zone "baidu.com" IN {
        type master;
        file "named.openlab.com";
};


$TTL 1D
@       IN      SOA     @       admin.admin.com. (
                                                0
                                                1D
                                                1H
                                                1W
                                                1H )
        IN      NS      ns.openlab.com.
		IN 		MX		10 mail.openlab.com.
ns      IN      A       192.168.159.129
mail    IN      A       192.168.159.129
www     IN      A       192.168.159.10
ftp     IN      A       192.168.159.20
vsftp   IN      CNAME   ftp

另外一台linux主机修改dns为192.168.159.129
解析测试

[root@yy ~]# nslookup www.openlab.com
Server:		192.168.159.129
Address:	192.168.159.129#53
Name:	www.openlab.com
Address: 192.168.159.10


[root@yy ~]# dig -t A www.openlab.com
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7 <<>> -t A www.openlab.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48244
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

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

;; ANSWER SECTION:
www.openlab.com.	86400	IN	A	192.168.159.10

;; AUTHORITY SECTION:
openlab.com.		86400	IN	NS	ns.openlab.com.

;; ADDITIONAL SECTION:
ns.openlab.com.		86400	IN	A	192.168.159.129

;; Query time: 0 msec
;; SERVER: 192.168.159.129#53(192.168.159.129)
;; WHEN: 日 2月 10 16:13:46 CST 2019
;; MSG SIZE  rcvd: 93

1、DNS服务器查询的类型:
(1)递归:客户端仅发出一次请求,让DNS服务器去查询返回结果;
(2)迭代:要发出多次请求去分别查询不同的DNS服务器;
2、DNS名称解析方式:
(1)正向解析:FQDN—>IP
(2)反向解析:IP—>FQDN
3、DNS服务器类型:
(1)主DNS服务器:负责解析至少一个域,数据修改(接受用户请求返回数据) master
(2)辅助(从)DNS服务器:定期请求数据同步 slave
(3)缓存DNS服务器:只缓存DNS数据 hint
(4)转发器:只转发数据 forward
4、资源记录类型;
(1)A记录:正向解析,将主机名映射到ipv4地址
(2)NS记录:将自己的域名映射到DNS服务器,用来指定该域名由哪个DNS服务器来解析
(3)CNAME记录别名:记录域别名
(4)MX记录:邮件交换记录
(5)PTR记录:反向解析,将一个ip地址映射到主机名
(6)SOA: 具体负责哪一个区域的解析
(7)AAAA :将主机名映射到ipv6地址
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值