DNS服务器的配置

要求:配置DNS服务的正反向简析

一,正向解析

1,安装bind(提供DNS服务)

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

2,对配置文件进行修改

(1)/etc/named.conf(主配置文件)


 11         listen-on port 53 { any; };
 19         allow-query     { any; };

(2)/etc/named.rfc1912.zones

zone "openlab.com" IN {
        type master;
        file "openlab.com.zone";
        allow-update { none; };
};

(3)/var/named

创建存储保存域名和IP地址映射关系的数据文件


[root@server named]# cp -a named.localhost openlab.com.zone 
[root@server named]# vim openlab.com.zone
$TTL 1D
@       IN SOA  ns.openlab.com. admin.qq.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN      NS      ns.openlab.com.
ns      IN      A       192.168.111.128
master  IN      A       192.168.111.128
www     IN      A       192.168.111.128
bbs     IN      A       192.168.111.128

3,关闭防火墙并重启服务

[root@server named]# systemctl stop firewalld
[root@server named]# systemctl restart named

4,测试

在第二台虚拟机上将DNS服务器IP改成服务器IP

[connection]
id=ens160
uuid=8eff1602-2daa-3ec2-ad30-6c5cf9f65b97
type=ethernet
autoconnect-priority=-999
interface-name=ens160
timestamp=1681106532
 
[ethernet]
 
[ipv4]
address1=192.168.111.136/24,192.168.111.2
dns=192.168.111.128;
method=manual
 
[ipv6]
addr-gen-mode=eui64
method=auto
 
[proxy]

重新加载网卡

[root@node ~]# nmcli connection reload 
[root@node ~]# nmcli connection up ens160 

在另一台客户端测试

[root@node ~]# nslookup www.openlab.com
Server:		192.168.111.128
Address:	192.168.111.128#53
 
Name:	www.openlab.com
Address: 192.168.111.128
 
 
 
[root@node ~]# host -a www.openlab.com
Trying "www.openlab.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48983
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.openlab.com.		IN	ANY
;; ANSWER SECTION:
www.openlab.com.	86400	IN	A	192.168.111.128
Received 49 bytes from 192.168.38.128#53 in 5 ms

二,反向解析

1,对配置文件进行修改

/etc/named.rfc1912.zones      区域配置文件(zone)

zone "38.168.192.in-addr.arpa" IN {
        type master;
        file "192.168.111.arpa";
        allow-update { none; };
};
 

/var/named/192.168.38.arpa

创建存储保存域名和IP地址映射关系的数据文件
 

[root@server named]# cp -a named.loopback 192.168.111.arpa 
[root@server named]# vim openlab.com.zone

注意,重启服务

测试

[root@node ~]# nslookup 192.168.111.128
128.111.168.192.in-addr.arpa	name = www.openlab.com.
128.111.168.192.in-addr.arpa	name = mail.openlab.com.
128.111.168.192.in-addr.arpa	name = ns.openlab.com.
128.111.168.192.in-addr.arpa	name = bbs.openlab.com.
 

完成

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