配置dns服务的正向解析

1、编辑/etc/named.conf文件

编辑以下内容:修改解析的主机为自己:listen-on port 53 { 192.168.153.133; };

并且允许的用户为153网段的所有人:allow-query     { 192.168.153.0/24; };

[root@at ~]# vim /etc/named.conf
 
 
options {
        listen-on port 53 { 192.168.153.133; };
        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.153.0/24; };

修改区域配置文件,添加正向区域配置,在其最后添加

zone "abc.com" IN{                                       #正向解析abc.com区域
        type master;                                          #类型为主区域服务器配置
        file "abc.zone";                                      #指定区域解析文件为abc.zone
        };

zone "abc.com"  IN {
              type master;
              file "abc.zone";
};
 
:wq 保存并退出

2、进入到/var/named下,创建并进去abc.zone文本,编辑以下内容

[root@at ~]# cd /var/named/
[root@at named]# vim abc.zone
 
 
$TTL 1D
@ IN SOA dns1.abc.com. test.163.com (
                                      0     ;serial   #序列号,主从同步序列号越大代表越新
                                      1D    ;refresh  #刷新时间
                                      1H    ;retry    #请求dns请求不到重试时间间隔
                                      1W    ;expire   #和主dns连接不上的时候,失效时间不在请求
                                      3H )  ;minimum  #最小的刷新时间
    IN NS dns1.abc.com.
    IN MX 10 mail.abc.com.
dns1.abc.com.          IN A 192.168.153.133
dns2.abc.com.          IN A 172.16.0.253
fileserver.abc.com.    IN A 172.16.0.100
printserver.abc.com.   IN A 172.16.0.101
www.abc.com.           IN A 172.16.0.200
www.abc.com.           IN A 172.16.0.201
mail.abc.com.          IN A 172.16.0.25
ntp.abc.com.           IN A 172.16.0.22
;CNAME: www.abc.com.  -> web.abc.com.
web  IN  CNAME www                                   #别名:web.abc.com

启动服务: systemctl  restart  named

[root@at named]# systemctl restart named

3、测试

[root@at named]# nslookup dns1.abc.com 192.168.153.133
Server:		192.168.153.133
Address:	192.168.153.133#53
 
Name:	dns1.abc.com
Address: 192.168.153.133
 
[root@at named]# nslookup dns2.abc.com 192.168.153.133
Server:		192.168.153.133
Address:	192.168.153.133#53
 
Name:	dns2.abc.com
Address: 172.16.0.253
 
[root@at named]# nslookup fileserver.abc.com 192.168.153.133
Server:		192.168.153.133
Address:	192.168.153.133#53
 
Name:	fileserver.abc.com
Address: 172.16.0.100
 
[root@at named]# nslookup printserver.abc.com 192.168.153.133
Server:		192.168.153.133
Address:	192.168.153.133#53
 
Name:	printserver.abc.com
Address: 172.16.0.101
 
[root@at named]# nslookup www.abc.com 192.168.153.133
Server:		192.168.153.133
Address:	192.168.153.133#53
 
Name:	www.abc.com
Address: 172.16.0.200
Name:	www.abc.com
Address: 172.16.0.201
 
[root@at named]# nslookup mail.abc.com 192.168.153.133
Server:		192.168.153.133
Address:	192.168.153.133#53
 
Name:	mail.abc.com
Address: 172.16.0.25
 
[root@at named]# nslookup ntp.abc.com 192.168.153.133
Server:		192.168.153.133
Address:	192.168.153.133#53
 
Name:	ntp.abc.com
Address: 172.16.0.22

你可能感兴趣的:(Linux,服务器,linux,网络)