为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地址