實驗要求: 1、建立DNS伺服器,負責解析的域為openedu.com 2、要求將MX記錄指向mail.openedu.com,且對應A記錄為本機IP 3、要求將NS記錄指向ns1.openedu.com,且對應A記錄為本機IP 4、建立www的A記錄指向本機IP; 建立ftp對應A記錄為x.x.x ...
實驗要求:
1、建立DNS伺服器,負責解析的域為openedu.com
2、要求將MX記錄指向mail.openedu.com,且對應A記錄為本機IP
3、要求將NS記錄指向ns1.openedu.com,且對應A記錄為本機IP
4、建立www的A記錄指向本機IP; 建立ftp對應A記錄為x.x.x.123; 為mail主機建立別名記錄pop3和smtp
5、為所有A記錄建立PTR記錄
6、openedu.com區域僅允許本網段中的主機x.x.x.200(NS為ns2.openedu.com)做區域傳送; 對應的反向區域不允許任何主機做區域傳送
7、客戶端測試
1、安裝bind軟體
[root@node01 ~]# yum install bind -y
2、修改主配置文件
[root@node01 ~]# vim /etc/named.conf
# 註釋一行,改倆行
listen-on port 53 { 192.168.11.110; };
//listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { 192.168.11.0/24; }; # 修改為本網段,或者用any
3、修改區域文件
[root@node01 ~]# vim /etc/named.rfc1912.zones
zone "openedu.com" IN {
type master;
file "openedu.com.zone";
};
zone "11.168.192.in-addr.arpa" IN {
type master;
file "192.168.11.zone";
};
4、拷貝模板解析文件
[root@node01 named]# cat openedu.com.zone
$TTL 1D
@ IN SOA dns1.openedu.com. admin.openedu.com. (
2023032001 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns1.openedu.com.
MX 5 mail.openedu.com.
dns1 A 192.168.11.110
mail A 192.168.11.110
www A 192.168.11.110
ftp A 192.168.11.123
pop3 CNAME mail
smtp CNAME mail
5、語法檢測
[root@node01 named]# named-checkzone openedu.com /var/named/openedu.com.zone
zone openedu.com/IN: loaded serial 2023032001
OK
6、重啟服務
[root@node01 named]# systemctl restart named
7、客戶端測試
# 安裝工具
[root@node02 ~]# yum install bind-utils.x86_64 -y
[root@node02 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.11.110
# 測試命令
> www.openedu.com
Server: 192.168.11.110
Address: 192.168.11.110#53
Name: www.openedu.com
Address: 192.168.11.110
> mail.openedu.com
Server: 192.168.11.110
Address: 192.168.11.110#53
Name: mail.openedu.com
Address: 192.168.11.110
> pop3.openedu,com
^C
[root@node02 ~]# nslookup
> pop3.openedu.com
Server: 192.168.11.110
Address: 192.168.11.110#53
pop3.openedu.com canonical name = mail.openedu.com.
Name: mail.openedu.com
Address: 192.168.11.110
[root@node02 ~]# nslookup
> ftp.openedu.com
Server: 192.168.11.110
Address: 192.168.11.110#53
Name: ftp.openedu.com
Address: 192.168.11.123
> pop3.openedu.com
Server: 192.168.11.110
Address: 192.168.11.110#53
pop3.openedu.com canonical name = mail.openedu.com.
Name: mail.openedu.com
Address: 192.168.11.110
8、修改反向解析域
[root@node01 named]# cat 192.168.11.zone
$TTL 1D
@ IN SOA dns1.openedu.com. admin.openedu.com. (
2023032001 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns1.openedu.com.
dns1.openedu.com. A 192.168.11.110
110 PTR dns1.openedu.com.
110 PTR mail.openedu.com.
110 PTR www.openedu.com.
123 PTR ftp.openedu.com.
9、語法檢測
[root@node01 named]# named-checkzone openedu.com 192.168.11.zone
zone openedu.com/IN: loaded serial 2023032001
OK
10、重啟服務
[root@node01 named]# systemctl restart named
11、客戶端測試
[root@node02 ~]# host -t PTR 192.168.11.110
110.11.168.192.in-addr.arpa domain name pointer www.openedu.com.
110.11.168.192.in-addr.arpa domain name pointer dns1.openedu.com.
110.11.168.192.in-addr.arpa domain name pointer ftp.openedu.com.
110.11.168.192.in-addr.arpa domain name pointer mail.openedu.com.
[root@node02 ~]# host -t PTR 192.168.11.123
123.11.168.192.in-addr.arpa domain name pointer ftp.openedu.com.
12、添加允許傳送的從伺服器,allow-transfer { address_match_elment;...};
[root@node01 named]# vim /etc/named.conf
options {
listen-on port 53 { 192.168.11.110; };
//listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { 192.168.11.0/24; };
allow-transfer { 192.168.11.200;};
13、添加NS2
[root@node01 named]# vim openedu.com.zone
$TTL 1D
@ IN SOA dns1.openedu.com. admin.openedu.com. (
2023032002 ; serial #註意手動修改序列號
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns1.openedu.com.
NS dns2.openedu.com.
MX 5 mail.openedu.com.
dns1 A 192.168.11.110
dns2 A 192.168.11.200
mail A 192.168.11.110
www A 192.168.11.110
ftp A 192.168.11.123
pop3 CNAME mail
smtp CNAME mail
14、語法檢測+重啟服務
[root@node01 named]# named-checkzone openedu.com openedu.com.zone
zone openedu.com/IN: loaded serial 2023032002
OK
[root@node01 named]# systemctl restart named
15、客戶端測試
反向解析:
[root@node02 ~]# host -t PTR 192.168.11.123
123.11.168.192.in-addr.arpa domain name pointer ftp.openedu.com.
[root@node02 ~]# host -t PTR 192.168.11.110
110.11.168.192.in-addr.arpa domain name pointer mail.openedu.com.
110.11.168.192.in-addr.arpa domain name pointer www.openedu.com.
110.11.168.192.in-addr.arpa domain name pointer dns1.openedu.com.
正向解析
[root@node02 ~]# nslookup
> www.openedu.com.
Server: 192.168.11.110
Address: 192.168.11.110#53
Name: www.openedu.com
Address: 192.168.11.110
> mail.openedu.com
Server: 192.168.11.110
Address: 192.168.11.110#53
Name: mail.openedu.com
Address: 192.168.11.110
> dns2.openedu.com
Server: 192.168.11.110
Address: 192.168.11.110#53
Name: dns2.openedu.com
Address: 192.168.11.200
作者:ChAn 出處:http://www.cnblogs.com/sre-chan/實驗完成,恢復環境
-------------------------------------------
個性簽名:今天做了別人不想做的事,明天你就做得到別人做不到的事,嘗試你都不敢,你拿什麼贏!
如果覺得這篇文章對你有小小的幫助的話,記得在右下角點個“推薦”哦,博主在此感謝!