码迷,mamicode.com
首页 > 其他好文 > 详细

centos7 dns(bind)安装配置

时间:2019-08-13 15:25:00      阅读:72      评论:0      收藏:0      [点我收藏+]

标签:xxx   yum   hat   lib   div   util   启动   配置文件   -o   

yum install -y bind bind-chroot bind-utils

chroot是通过相关文件封装在一个伪根目录内,已达到安全防护的目的,一旦程序被攻破,将只能访问伪根目录内的内容,而不是真实的根目录
BIND安装好之后不会有预制的配置文件,但是在BIND的文档文件夹内(/usr/share/doc/bind-9.9.4),BIND为我们提供了配置文件模板,我们可以直接拷贝过来:

cp -r /usr/share/doc/bind-9.9.4/sample/etc/* /var/named/chroot/etc/
cp -r /usr/share/doc/bind-9.9.4/sample/var/* /var/named/chroot/var/

配置BIND服务的主配置文件(/var/named/chroot/etc/named.conf),命令:vim /var/named/chroot/etc/named.conf;
内容很多使用简单配置,删除文件中logging以下的全部内容,以及option中的部分内容,得到如下配置

vim /var/named/chroot/etc/named.conf
options
 {
         // Put files that named is allowed to write in the data/ directory:
         directory               "/var/named";           // "Working" directory
         listen-on port 53       { any; };

         listen-on-v6 port 53    { any; };

 };

 在主配置文件(/var/named/chroot/etc/named.conf )中加入,zone参数

vim /var/named/chroot/etc/named.conf
 options
 {
         // Put files that named is allowed to write in the data/ directory:
         directory               "/var/named";           // "Working" directory
         listen-on port 53       { any; };

         listen-on-v6 port 53    { any; };

 };


zone "yaohjk.com" {
  type master;
  file "yaohjk.com.zone";
};

新建yaohjk.com.zone文件,yaohjk.com的域名解析文件,zone文件放在/var/named/chroot/var/named/下,zone文件可以已/var/named/chroot/var/named/named.localhost为模板。
命令:

cp /var/named/chroot/var/named/named.localhost /var/named/chroot/var/named/yaohjk.com.zone

文件yaohjk.com.zone的内容如下:

[root@xxx]# cat yaohjk.com.zone 
$TTL 1D
@    IN SOA    @ rname.invalid. (
                    0    ; serial
                    1D    ; refresh
                    1H    ; retry
                    1W    ; expire
                    3H )    ; minimum
    NS    @
    A    127.0.0.1
    AAAA    ::1
gz         IN A       192.168.0.199
boss       IN A       192.168.0.199
login      IN A       192.168.0.199
pay        IN A       192.168.0.199
wx         IN A       192.168.0.199

禁用bind默认方式启动,改用bind-chroot方式启动。命令如下:

[root@xxx named]# /usr/libexec/setup-named-chroot.sh /var/named/chroot on
[root@xxx named]# systemctl stop named
[root@xxx named]# systemctl disable named
[root@xxx named]# systemctl start named-chroot
[root@xxx named]# systemctl enable named-chroot
[root@xxx named]#
[root@xxx named]# ps -ef|grep named
named    25984     1  0 13:41 ?        00:00:00 /usr/sbin/named -u named -c /etc/named.conf -t /var/named/chroot
root     29267 48688  0 13:54 pts/1    00:00:00 grep --color=auto named
[root@xxx named]# 

 

 

centos7 dns(bind)安装配置

标签:xxx   yum   hat   lib   div   util   启动   配置文件   -o   

原文地址:https://www.cnblogs.com/jiangwenhui/p/11345751.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!