配置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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我和程序有一个能跑就行

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值