DNS解析综合学习案例
1、用户需把/dev/myvg/mylv逻辑卷以支持磁盘配额的方式挂载到网页目录下
2、在网页目录下创建测试文件index.html,内容为用户名称,通过浏览器访问测试
3、创建用户账户,对LVM配置磁盘配额限制用户磁盘容量为软限制80M;硬限制100M、文件数量软限制为80个;硬限制为100个。
4、构建主从DNS域名解析环境
5、主从DNS都可将www.study.com域名解析为192.168.200.113
6、客户机可通过浏览器访问www.study.com得到WEB服务器相应内容
7、主域名服务器要同时担任缓存域名服务器功能
8、客户机通过nslookup域名测试工具可解析到www.jd.com等网站的域名解析结果
详细代码请查看:https://www.cnblogs.com/elin989898/p/11378204.html
解析如下:
逻辑卷构建
1-4题 详情请见: https://www.cnblogs.com/elin989898/p/11303317.html
注意事项,逻辑卷格式化后挂载,源码安装要在逻辑卷挂载后在安装。
源码安装参考:https://www.cnblogs.com/elin989898/p/11255514.html
DNS服务搭建
4-8题解析
主服务器安装配
[root@localhost ~]# rpm -qa |grep "bind" //检索DNS所依赖的安装包3个 ,bind bind-utils bind-libs
bind-utils-9.9.4-50.el7.x86_64
bind-license-9.9.4-50.el7.noarch
bind-libs-9.9.4-50.el7.x86_64
rpcbind-0.2.0-42.el7.x86_64
bind-libs-lite-9.9.4-50.el7.x86_64
[root@localhost ~]# yum -y install bind //安装bind
# Generated by NetworkManager
nameserver 202.106.0.20
nameserver 192.168.116.10 //自己定义IP 但是前后使用要保持一致,且必须与主机IP处于同一网段
nameserver 192.168.116.20
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.116.10 ns1.study.com
192.168.116.20 ns2.study.com //设置主机名,注意格式 一个(ns1) 是主服务器,一个(ns2)是从服务器
options {
directory "/var/named"; //指定文件路径
};
zone "study.com" IN { // study.com 是正向解析 跟主机名保持一致
type master; //类型是主服务器
file "elin.zheng"; //正向解析文件名
allow-transfer { 192.168.116.20; }; //从服务器的IP地址,注意前后保持一致
};
zone "116.168.192.in-addr.arpa" IN { //反向解析 IP倒着写 ,192.168.116.* 倒着写只写网段 即116.168.192.in-addr.arpa 注意不要写错,格式字母,标点符号都不能错
type master; //类型主服务器
file "elin.fan"; //反向文件解析名
allow-transfer { 192.168.116.20; }; //指向从服务器的IP 注意{与IP地址之间前后有空格 IP地址后面有;
};
[root@localhost ~]# cat /var/named/elin.zheng
$TTL 86400 //生命周期值 84600指的是1天
@ IN SOA study.com. admin.study.com.( //注意名字study.com后面有.
20190819
3H
15M
1W //注意正向解析是通过域名解析处IP地址 反向解析是IP地址解析出域名
)
IN NS ns1.study.com.
IN NS ns2.study.com.
IN MX 10 mail.study.com.
ns2 IN A 192.168.116.20
mail IN A 192.168.116.21
www IN A 192.168.116.22
[root@localhost ~]# vim /var/named/elin.fan //编辑反向解析文件
[root@localhost ~]# cat /var/named/elin.fan //写入以下内容
$TTL 86400
@ IN SOA study.com. admin.study.com. (
20190817
3H
15M
1W
1D
)
IN NS ns1.study.com.
IN NS ns2.study.com.
IN MX 10 mail.study.com.
10 IN PTR ns1.study.com.
20 IN PTR ns2.study.com.
21 IN PTR mail.study.com.
22 IN PTR www.study.com. 注意与正向解析内容保持一致,而且最前面表示IP地址的最后一位
[root@localhost ~]# named-checkconf -z /etc/named.conf //检查 /etc/named.conf
zone study.com/IN: loaded serial 20190819
zone 116.168.192.in-addr.arpa/IN: loaded serial 20190817
[root@localhost ~]# named-checkzone study.com /var/named/elin.zheng //测试正向文件是否能被读取
zone study.com/IN: loaded serial 20190819
OK
[root@localhost ~]# named-checkzone 116.168.192.in-addr.arpa /var/named/elin.fan //测试反向文件是否能被读取
zone 116.168.192.in-addr.arpa/IN: loaded serial 20190817
OK
[root@localhost ~]# systemctl start named //启动服务
[root@localhost ~]#
[root@localhost ~]# systemctl stop firewalld // 关闭防火墙
[root@localhost ~]# setenforce 0 //关闭安全机制
setenforce: SELinux is disabled
bind-license-9.9.4-72.el7.noarch
bind-libs-lite-9.9.4-72.el7.x86_64
[root@localhost ~]# yum -y install bind bind-utils
[root@localhost ~]# vim /etc/hosts
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.116.10 ns1.study.com
192.168.116.20 ns2.study.com
[root@localhost ~]# vim /etc/resolv.conf
[root@localhost ~]# cat /etc/resolv.conf //同上操作不在说明
# Generated by NetworkManager
nameserver 202.106.0.20
nameserver 192.168.116.10
nameserver 192.168.116.20
[root@localhost ~]# cat /etc/named.conf
options {
directory "/var/named";
};
zone "study.com" IN {
type slave; //类型从服务器
file "slaves/elin.zheng"; //从服务器的正向解析文件
masters { 192.168.116.10; }; // 主服务器IP地址
};
zone "116.168.192.in-addr.arpa " IN {
type slave;
file "slaves/elin.zheng"; //从服务器的反向解析文件
masters { 192.168.116.10; }; //主服务器的IP地址
};
打开终端输入nslookup www.study.com //进行域名解析
搭建缓存服务器
在主服务器上
[root@localhost ~]# vim /etc/named.conf
[root@localhost ~]# cat /etc/named.conf
options {
listen-on port 53{ 192.168.116.66; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/nemed_men_stats.txt";
allow-query { any; };
forwarders { 202.106.0.20; };
recursion yes;
};
zone "study.com" IN {
type master;
file "elin.zheng";
allow-transfer { 192.168.116.20; };
};
zone "116.168.192.in-addr.arpa" IN {
type master;
file "elin.fan";
allow-transfer { 192.168.116.20; };
};
[root@localhost ~]# systemctl restart named //重启named
在windows 中进行测试 最后在终端中ping www.baidu.com