摒弃世俗浮躁
追求技术精湛

CentOS7搭建BIND9 DNS服务器过程

一、系统环境

CentOS7
BIND 9.9


二、安装bind

#yum -y install bind

三、配置安装

1、修改监听所有IP

#vim /etc/named.conf

listen-on port 53 { 127.0.0.1; };    修改为    listen-on port 53 { any; };
allow-query     { localhost; };      修改为    allow-query     { any; };

2.建立解析域(本地)

#vim /etc/named.rfc1912.zones

追加以下内容,上面的是正向解析,下面的为反向解析

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

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

 

可以检查一下配置是否正确,如果执行没有返回提示则表示正常

#named-checkconf

3.创建区域文件

正向解析:

#touch test.com.zone
#chown named:named test.com.zone
#vim test.com.zone

增加内容

$TTL 1D
@	IN SOA	test.com. rname.invalid. (
          0	; serial
          1D	; refresh
          1H	; retry
          1W	; expire
          3H )	; minimum
        NS      @
        A       127.0.0.1
        AAAA    ::1
ns	IN	A	192.168.2.244
node1	IN	A	192.168.2.245
node2	IN	A	192.168.2.246
node3	IN	A	192.168.2.250

 

反向解析:

#touch 192.168.2.arpa
#chown root:named 192.168.2.arpa
#vim 192.168.2.arpa

增加内容

$TTL 1D
@	IN SOA	test.com. rname.invalid. (
          0	; serial
          1D	; refresh
          1H	; retry
          1W	; expire
          3H )	; minimum
  IN	NS	@
  A	127.0.0.1
  AAAA	::1
  PTR	localhost.
ns	IN	A	192.168.2.244
244	IN	PTR	ns.test.com
245	IN	PTR	node1.test.com
246	IN	PTR	node2.test.com
250	IN	PTR	node3.test.com

四、测试

最后启动服务之前检查一下配置项是否正常

[root@bogon named]# named-checkzone "test.com" /var/named/test.com.zone 
zone test.com/IN: loaded serial 0
OK
[root@bogon named]# named-checkzone "192.168.2.in-addr.arpa" /var/named/192.168.2.arpa 
zone 192.168.2.in-addr.arpa/IN: loaded serial 0
OK

 

OK,没问题,启动服务 进行测试:

[root@bogon named]# systemctl start named
[root@bogon named]# nslookup
> server 192.168.2.250
Default server: 192.168.2.250
Address: 192.168.2.250#53
> node1.test.com
Server:		192.168.2.250
Address:	192.168.2.250#53

Name:	node1.test.com
Address: 192.168.2.245
> node2.test.com
Server:		192.168.2.250
Address:	192.168.2.250#53

Name:	node2.test.com
Address: 192.168.2.246
> 192.168.2.244
Server:		192.168.2.250
Address:	192.168.2.250#53

244.2.168.192.in-addr.arpa	name = ns.test.com.2.168.192.in-addr.arpa.

 

赞(3) 打赏
未经允许不得转载:时光日记 » CentOS7搭建BIND9 DNS服务器过程

评论 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

登录

找回密码

注册