centos部署bind DNS服务器

一、安装bind

yum install -y bind bind-chroot bind-utils

二、修改/etc/named.conf配置文件

//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
// See the BIND Administrator's Reference Manual (ARM) for details about the
// configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html
options {
	listen-on port 53 { 192.168.10.9; };  #DNS服务器IP
	//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";
	//recursing-file  "/var/named/data/named.recursing";
	//secroots-file   "/var/named/data/named.secroots";
	allow-query     { any; };
	/* 
	 - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
	 - If you are building a RECURSIVE (caching) DNS server, you need to enable 
	   recursion. 
	 - If your recursive DNS server has a public IP address, you MUST enable access 
	   control to limit queries to your legitimate users. Failing to do so will
	   cause your server to become part of large scale DNS amplification 
	   attacks. Implementing BCP38 within your network would greatly
	   reduce such attack surface 
	*/
	recursion yes;
	forwarders      { 114.114.114.114;8.8.8.8;};        #转发外部DNS,本地DNS无法解析会转发到这两个外部DNS
	dnssec-enable no;
	dnssec-validation no;
	/* Path to ISC DLV key */
	bindkeys-file "/etc/named.root.key";
	managed-keys-directory "/var/named/dynamic";
	pid-file "/run/named/named.pid";
	session-keyfile "/run/named/session.key";
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
zone "." IN {
	type hint;
	file "named.ca";
};

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

三、修改/etc/named.rfc1912.zones配置文件

......

zone "test.com" IN {    #添加域
        type master;    #master为主DNS
        file "test.com.zone";    #dns配置文件名,路径在:/var/named/
        allow-update { none; };  #不允许任何DNS服务器向此更新
};

......

四、配置/var/named/test.com.zone配置文件

$ORIGIN test.com.
$TTL 1D
@       IN SOA  @ admn.test.com. (
                                        0       ; serial #更新序列号
                                        1D      ; refresh #更新时间
                                        1H      ; retry #重试延时
                                        1W      ; expire #失效时间
                                        3H )    ; minimum #无效解析记录的缓存时间
        NS      test.com.               ;域名服务器记录
        A       192.168.10.9            ;DNS服务器IPv4地址
;       AAAA    ::1                     ;服务器IPv6地址

; HOST RECORDS
zk1.zookeeper        3600 IN A 192.168.10.2
zk2.zookeeper        3600 IN A 192.168.10.3
zk3.zookeeper        3600 IN A 192.168.10.4

五、启动bind服务

systemctl start named

#修改解析配置reload命令:rndc reload

六、在内网服务器/etc/resolv.conf添加本地dns服务器IP,至此dns部署完成

nameserver 192.168.10.9

注意:如果无法解析,确认TCP/UDP端口53是否能访问

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值