【无标题】

DNS正向解析和反向解析
1.挂载

[root@localhost ~]# mount /dev/sr0 /mnt

2.安装bind软件包

[root@localhost ~]# yum install bind -y

3.关闭防火墙

[root@localhost ~]# systemctl disable firewalld --now
[root@localhost ~]# setenforce 0

4.在配置文件里编辑

[root@localhost ~ named]# vim /etc/named.conf
options {
        listen-on port 53  192.168.61.129; };
        directory    "var/named";
        allow-query {localhost;};
};
logging {
        channel default debug {
                file "data/named.run";
                severity dynamic;
         };
zone"openlab.com" IN {
        type master;
        file "named.openlab .com";
};
zone "88.168.192.in-addr.arpa" IN [
        type master;
        file"named.openlab .com";
};

5.更改/var/named/named.openlab.com文件和/etc/resolv.conf文件

[root@localhost ~]# vim /var/named/named.openlab.com 
 
 
@       IN      SOA     ns.openlab.com. admin.qq.com.  (
                                                2023051002
                                                1M
                                                1M
                                                1M
                                                3M )
                NS      ns.openlab.com.
ns              A       192.168.61.131
ftp             A       192.168.61.132
www             A       192.168.61.133
http            CNAME   www
 
[root@localhost ~]# vim /etc/resolv.conf 
 
# Generated by NetworkManager
search localdomain
nameserver 192.168.88.129

6.测试

[root@localhost ~]# host www.openlab.com
www.openlab.com has address 192.168.61.133

二.DNS反向解析
1.安装bind

[root@localhost ~]# yum install bind -y

2.关闭防火墙

[root@localhost ~]# systemctl disable firewalld --now
[root@localhost ~]# setenforce 0

3.更改配置文件/etc/name.conf

[root@localhost ~]# vim /etc/named.conf
 
options {
        listen-on port 53 { 192.168.61.131; };
        directory       "/var/named";
        allow-query     { any; };
        recursion yes;
};
 
#正向解析
zone "openlab.com" IN {
        type master;
        file "named.openlab.com";
};
 
#反向解析
zone "88.168.192.in-addr.arpa" IN {
        type master;
        file "named.openlab.com";
};

4.更改/var/named/named.openlab.com文件和/etc/resolv.conf文件

[root@localhost ~]# vim /var/named/named.openlab.com 
 
$TTL    1D
@       IN      SOA     ns.openlab.com. admin.qq.com.  (
                                                2023051002
                                                1M
                                                1M
                                                1M
                                                3M )
                NS      ns.openlab.com.
ns              A       192.168.61.131
ftp             A       192.168.61.132
www             A       192.168.61.133
http            CNAME   www
130             PTR     ns.openlab.com.
131             PTR     www.openlab.com.
132             PTR     ftp.openlab.com.
 
[root@localhost ~]# vim /etc/resolv.conf 
 
# Generated by NetworkManager
search localdomain
nameserver 192.168.61.128

5.客户端测试,反向测试结果如下:

[root@localhost ~]# nslookup 192.168.61.132
132.61.168.192.in-addr.arpa	name = ftp.openlab.com.
 
[root@localhost ~]# nslookup 192.168.61.133
133.61.168.192.in-addr.arpa	name = www.openlab.com.
 
[root@localhost ~]# nslookup 192.168.61.131
131.61.168.192.in-addr.arpa	name = ns.openlab.com

.

你可能感兴趣的:(linux)