Hostname Resolution Server Configuration
Require:
1. Establish a DNS server, and the domain responsible for resolution is openedu.com;
Establishing DNS first requires configuring the main configuration file on the server side :
options {
listen-on port 53 { 192.168.159.128; }; 监听端口和ip
// listen-on-v6 port 53 { ::1; };
directory "/var/named";dns文件目录
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";
secroots-file "/var/named/data/named.secroots";
recursing-file "/var/named/data/named.recursing";
allow-query { 192.168.159.0/24; };允许那些网段进行dns解析请求
Create a new forward zone (namely, the mapping file from domain name to ip address) as follows:
zone "openedu.com" {
type master;
file "openedu.com.zone";
};
(2) Check whether the format of the zone file is correct: named-checkconf
Next, add the following requirements to the forward zone file according to the requirements:
(3) First enter the cd /var/named/ path
(4) Because of the permission problem here, you need to use the cp command to create a new forward zone file: cp -p named.localhost openedu.com.zone
(5) Enter the file to complete the requirements of 2, 3, and 4:
2. It is required to point the MX record to mail.openedu.com, and the corresponding A record is the local IP;
MX 5 mail.openedu.com.
ns1 A 192.168.159.128
3. It is required to point the NS record to ns1.openedu.com, and the corresponding A record is the local IP;
NS ns1.openedu.com.
mail A 192.168.159.128
4. Create the A record of www to point to the local IP; create ftp corresponding A record as xxx123; create alias records pop3 and smtp for the mail host;
www A 192.168.159.128
mail A 192.168.159.128
pop3 CNAME mail
smtp CNAME mail
(6) Total:
$TTL 1D
@ IN SOA ns1.openedu.com. admain.openedu.com (
2023041501 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS ns1.openedu.com.
MX 5 mail.openedu.com.
ns1 A 192.168.159.128
www A 192.168.159.128
ftp A 192.168.159.123
mail A 192.168.159.128
pop3 CNAME mail
smtp CNAME mail
(7) Check whether the file format is correct: named-checkzone openedu.com openedu.com.zone
5. Create PTR records for all A records;
Create a new reverse zone :
(1) Enter the zone file: vim /etc/named.rfc1912.zones
zone "159.168.192.1.in-addr.arpa" IN {
type master;
file "192.168.159.1.zone";
};
(2) Create a new reverse zone file: cp -p named.loopback 192.168.159.1.zone
(3) Configure all reverse parsing:
$TTL 1D
@ IN SOA ns1.openedu.com. admin.openedu.com. (
2023041501 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS ns1.openedu.com.
ns1.openedu.com. A 192.168.159.128
128 PTR ns1.openedu.com.
PTR www.openedu.com.
PTR mail.openedu.com.
123 PTR ftp.openedu.com.
(4) Check whether the format of the reverse zone file is correct: named-checkzone openedu.com 192.168.159.1.zone
Here is a simple test :
First restart the named service on both the client and server;
Then you need to install the test software on the client: yum install -y nfs-utils
Test on client:
Try to resolve the domain name:
[root@client ~]# nslookup ftp.openedu.com 192.168.159.128
Server: 192.168.159.128
Address: 192.168.159.128#53
Name: ftp.openedu.com
Address: 192.168.159.123
Try to resolve ip:
[root@client ~]# nslookup 192.168.159.128 192.168.159.128
128.159.168.192.in-addr.arpa name = dns1.openlab.edu.
128.159.168.192.in-addr.arpa name = web.openlab.edu.
128.159.168.192.in-addr.arpa name = www.openlab.edu.
6. The openedu.com area only allows the host xxx200 (NS is ns2.openedu.com) in this network segment to do area transfer; the corresponding reverse area does not allow any host to do area transfer;
allow-transfer {192.168.159.132;}; 允许从服务器进行区域传送的ip
(2) Add the slave server in the forward zone file: vim openedu.com.zone
(3) Because the reverse zone is required not to perform zone transfers to any host, there is no need to increase the ns2 of the reverse zone;
(4) Check whether the file format is correct:
from server (client)
options {
listen-on port 53 { 192.168.159.132; }; 修改监听端口为本地ip
// 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";
secroots-file "/var/named/data/named.secroots";
recursing-file "/var/named/data/named.recursing";
allow-query { 192.168.159.0/24; }; 配置允许的ip网段
(3) Add forward zone file: vim /etc/named.rfc1912.zones
zone "openedu.com" IN {
type slave;
file "slaves/openedu.com.zone";
masters{192.168.159.128;};
};
(4) Check whether the file format is correct: named-checkconf
7. Client testing;
Both the server and the client need to restart the named service before the test: systemctl restart named
View the zone files transferred from the master server on the slave server: ll /var/named/slaves/
meets the requirements of the topic and only transfers a forward file without a reverse file:
-rw-r--r--. 1 named named 586 4月 15 10:31 openedu.com.zone
Try to resolve the domain name: host -ta www.openedu.com 192.168.159.132
Using domain server:
Name: 192.168.159.132
Address: 192.168.159.132#53
Aliases:
www.openedu.com has address 192.168.159.128
success!
Try to resolve ip: nslookup 192.168.159.123 192.168.159.13
** server can't find 123.159.168.192.in-addr.arpa: NXDOMAIN
fail!