RHCE——DNS主从服务器配置

服务端:192.168.11.130

客户端:192.168.11.131

一、正向解析

1.安装DNS服务软件bind

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# yum install bind -y

2.更改主配置文件

[root@localhost ~]# vim /etc/named.conf
 
options {
        listen-on port 53 { 192.168.11.130; };
        directory       "/var/named";
        allow-query     { any; };
        recursion yes;
};
 
zone "openlab.com" IN {
        type master;
        file "named.openlab.com";
};
 

[root@localhost ~]# systemctl restart named

3.创建数据文件

[root@localhost ~]# vim /var/named/named.openlab.com
[root@localhost ~]# cat /var/named/named.openlab.com
 
$TTL 1D
@       IN  SOA  @  ns.openlab.com. admin.qq.com. (
                                                        202050500
                                                        1D
                                                        3H
                                                        12H
                                                        2D )
                NS     ns.openlab.com.
ns              A      192.168.11.130
www             A      192.168.11.130
ftp             A      192.168.11.131
wwww            CNAME  www
 
[root@localhost ~]# vim /etc/resolv.conf
 
# Generated by NetworkManager
search localdomain
nameserver 192.168.11.130
 

4.客户端测试

以下三种方式皆可:
[root@localhost ~]# nslookup  #针对windouws
[root@localhost ~]# dig -t A openlab.com    #针对linux
[root@localhost ~]# host www.openlab.com
www.openlab.com has address 192.168.11.130
二、反向解析

1.安装DNS服务软件bind

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# yum install bind -y

2.更改主配置文件

[root@localhost ~]# vim /etc/named.conf
 
options {
        listen-on port 53 { 192.168.11.131; };
        directory       "/var/named";
        allow-query     { any; };
        recursion yes;
};
 

zone "130.11.192.in-addr.arpa" IN {
        type master;
        file "named.openlab.com";
};

3.创建数据文件

[root@localhost ~]# vim /var/named/named.openlab.com 
 
$TTL    1D
@       IN      SOA     ns.openlab.com. admin.qq.com.  (
                                                2023051000
                                                1M
                                                1M
                                                1M
                                                3M )
 
130             PTR     ns.openlab.com.
128             PTR     www.openlab.com.
129             PTR     ftp.openlab.com.
 
[root@localhost ~]# vim /etc/resolv.conf 
 
# Generated by NetworkManager
search localdomain
nameserver 192.168.11.131

4.测试

[root@localhost ~]# nslookup 192.168.11.130
130.11.168.192.in-addr.arpa	name = www.openlab.com.

或者:

[root@localhost ~]# dig -x 1192.168.11.131

你可能感兴趣的:(服务器,运维)