N46期第九周作业

1、配置 bind 服务,实现 www.magedu.org 域名解析

 

 

服务端 10.0.0.71
yum install -y bind bind-utils;systemctl enable --now named

vim /etc/named.conf
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };

vim /etc/named.rfc1912.zones
zone "magedu.org" IN {
type master;
file "magedu.org.zone";
};

cp -p /var/named/named.localhost /var/named/magedu.org.zone

vim /var/named/magedu.org.zone
$TTL 1D
@ IN SOA master admin (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
master A 10.0.0.71
www A 10.0.0.83

named-checkconf

named-checkzone magedu.org.zone /var/named/magedu.org.zone

rndc reload

web端 10.0.0.83

yum install -y httpd;echo www.magedu.org > /var/www/html/index.html;systemctl enable --now httpd

[root@centos8 ~]#curl 10.0.0.83
www.magedu.org


客户端 10.0.0.61

vim /etc/sysconfig/network-scripts/ifcfg-eth0
DNS1=10.0.0.71

service network restart

[root@centos6 ~]#cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 10.0.0.71

[root@centos6 ~]#dig www.magedu.org

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6 <<>> www.magedu.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43660
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;www.magedu.org. IN A

;; ANSWER SECTION:
www.magedu.org. 86400 IN A 10.0.0.83

;; AUTHORITY SECTION:
magedu.org. 86400 IN NS master.magedu.org.

;; ADDITIONAL SECTION:
master.magedu.org. 86400 IN A 10.0.0.71

;; Query time: 0 msec
;; SERVER: 10.0.0.71#53(10.0.0.71)
;; WHEN: Sat Jul 25 21:49:12 2020
;; MSG SIZE rcvd: 85

2、配置 bind 服务,实现域名反向解析

 

 

接上面实验

服务端 10.0.0.71
vim /etc/named.rfc1912.zones
zone "0.0.10.in-addr.arpa" {
type master;
file "10.0.0.zone";
};

cp -p /var/named/named.loopback /var/named/10.0.0.zone

vim /var/named/10.0.0.zone
$TTL 1D
@ IN SOA ns1 admin (
1000 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS ns1.magedu.org.
100 PTR www.magedu.org.

named-checkconf

named-checkzone 0.0.10.in-addr.arpa 10.0.0.zone

rndc reload

客户端 10.0.0.61

[root@centos6 ~]#dig -x 10.0.0.100

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6 <<>> -x 10.0.0.100
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1133
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;100.0.0.10.in-addr.arpa. IN PTR

;; ANSWER SECTION:
100.0.0.10.in-addr.arpa. 86400 IN PTR www.magedu.org.

;; AUTHORITY SECTION:
0.0.10.in-addr.arpa. 86400 IN NS ns1.magedu.org.

;; Query time: 1 msec
;; SERVER: 10.0.0.71#53(10.0.0.71)
;; WHEN: Sun Jul 26 11:37:22 2020
;; MSG SIZE rcvd: 87

 

3、配置 bind 服务,实现主从 DNS 服务配置:

 

 

 

主服务器 10.0.0.71
vim /etc/named.conf
allow-transfer { 10.0.0.72; };
dnssec-enable no;
dnssec-validation no;

vim /var/named/magedu.org.zone
$TTL 1D
@ IN SOA master admin (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
NS slave
master A 10.0.0.71
www A 10.0.0.83
slave A 10.0.0.72

named-checkconf

named-checkzone magedu.org.zone /var/named/magedu.org.zone

[root@centos7 ~]#rndc reload
server reload successful

从服务器 10.0.0.72
yum install -y bind bind-utils;systemctl enable --now named

vim /etc/named.conf
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
allow-transfer { none; };

vim /etc/named.rfc1912.zones
zone "magedu.org" IN {
type slave;
masters { 10.0.0.71;};
file "slaves/magedu.org.slave";
};

rndc reload

ll /var/named/slaves/magedu.org.slave
-rw-r--r--. 1 named named 319 Jul 26 10:00 magedu.org.slave

修改一下版本号,看是否能继续同步

$TTL 1D
@ IN SOA master admin (
1 ; serial #版本号改为1
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
NS slave
master A 10.0.0.71
www A 10.0.0.83
slave A 10.0.0.72

ll /var/named/slaves/magedu.org.slave
-rw-r--r--. 1 named named 319 Jul 26 10:03 magedu.org.slave #已同步

4、 配置 bind 服务,实现子域服务器:

 

 

 

接上面实验
父域服务器 10.0.0.71
vim /var/named/magedu.org.zone
$TTL 1D
@ IN SOA master admin (
1 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
NS slave
shandong NS shandongs #注意:最前面的shandong不能省略
master A 10.0.0.71
www A 10.0.0.83
slave A 10.0.0.72
shandongs A 10.0.0.84

named-checkconf

[root@centos7 ~]#named-checkzone magedu.org.zone /var/named/magedu.org.zone
zone magedu.org.zone/IN: loaded serial 1
OK

[root@centos7 ~]#rndc reload
server reload successful

子域服务器 10.0.0.84
yum install -y bind bind-utils;systemctl enable --now named

vim /etc/named.conf
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
allow-transfer { none; };

vim /etc/named.rfc1912.zones
zone "shandong.magedu.org" {
type master;
file "shandong.magedu.org.zone";
};

cp -p /var/named/named.localhost /var/named/shandong.magedu.org.zone

vim /var/named/shandong.magedu.org.zone
$TTL 1D
@ IN SOA master admin (
20072610 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
master A 10.0.0.84
websrv A 10.0.0.100
www CNAME websrv
db A 10.0.0.101
ab A 10.0.0.102

[root@centos8 ~]#named-checkconf

[root@centos8 ~]#named-checkzone shandong.magedu.org.zone /var/named/shandong.magedu.org.zone
zone shandong.magedu.org.zone/IN: loaded serial 20072610
OK

[root@centos8 ~]#rndc reload
server reload successful

客户端 10.0.0.61
[root@centos6 ~]#dig www.shandong.magedu.org

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6 <<>> www.shandong.magedu.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8610
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;www.shandong.magedu.org. IN A

;; ANSWER SECTION:
www.shandong.magedu.org. 86394 IN CNAME websrv.shandong.magedu.org.
websrv.shandong.magedu.org. 86394 IN A 10.0.0.100

;; AUTHORITY SECTION:
shandong.magedu.org. 86394 IN NS master.shandong.magedu.org.

;; ADDITIONAL SECTION:
master.shandong.magedu.org. 86394 IN A 10.0.0.84

;; Query time: 1 msec
;; SERVER: 10.0.0.71#53(10.0.0.71)
;; WHEN: Sun Jul 26 11:22:25 2020
;; MSG SIZE rcvd: 115

 

posted @ 2020-07-26 11:35  请你猜猜我是谁  阅读(110)  评论(0编辑  收藏  举报