/*
Sample named.conf BIND DNS server 'named' configuration file
for the Red Hat BIND distribution.
See the BIND Administrator's Reference Manual (ARM) for details, in:
file:///usr/share/doc/bind-{version}/arm/Bv9ARM.html
Also see the BIND Configuration GUI : /usr/bin/system-config-bind and
its manual.
*/
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 port 53 { 127.0.0.1; };
//listen-on-v6 port 53 { any; };
listen-on-v6 port 53 { ::1; };
};
zone "iyunv.com"
{
type master;
file "iyunv.com.zone";
};
修改后:
[iyunv@xiaoluo etc]# vim named.conf
/*
Sample named.conf BIND DNS server 'named' configuration file
for the Red Hat BIND distribution.
See the BIND Administrator's Reference Manual (ARM) for details, in:
file:///usr/share/doc/bind-{version}/arm/Bv9ARM.html
Also see the BIND Configuration GUI : /usr/bin/system-config-bind and
its manual.
*/
options
{
// Put files that named is allowed to write in the data/ directory:
directory "/var/named"; // "Working" directory
};
zone "iyunv.com"
{
type master;
file "iyunv.com.zone";
};
(4)开启我们的主DNS服务器的BIND服务
[iyunv@xiaoluo etc]# service named start
Starting named: named: already running [ OK ]
主DNS服务器的配置就基本这样子,接下来就是我们配置从DNS服务器的步骤了:
①首先我们也需要在从服务器上安装BIND服务,这块就省略了,具体安装上一篇随笔有详细讲解 Linux学习之CentOS(三十四)--配置域主DNS服务器
②在bind主配置文件中添加指定域的信息
我们只需要在named.conf配置文件下面添加如下信息就可:
zone "iyunv.com"
{
type slave;
masters { 192.168.198.129; };
file "slaves/iyunv.com.zone"
};
[iyunv@slave etc]# cat named.conf
/*
Sample named.conf BIND DNS server 'named' configuration file
for the Red Hat BIND distribution.
See the BIND Administrator's Reference Manual (ARM) for details, in:
file:///usr/share/doc/bind-{version}/arm/Bv9ARM.html
Also see the BIND Configuration GUI : /usr/bin/system-config-bind and
its manual.
*/
options
{
directory "/var/named"; // "Working" directory
};
zone "iyunv.com"
{
type slave; // 指定这是从DNS服务器
masters { 192.168.198.129; }; // 因为从DNS服务器要抓取主DNS服务器上的zone文件,这里要指定主DNS服务器的IP地址,注意:IP地址要用{}括起来,且以;结尾,前后都有空格
file "slaves/iyunv.com.zone"; // 从服务器默认抓取到的zone文件通常都保存在了 slaves 这个目录下
};
③关闭从服务器上的SELinux
因为要通过网络来访问主服务器,所以这里也需要将我们的SELinux设置成 permissive
[iyunv@slave etc]# getenforce
Enforcing
[iyunv@slave etc]# setenforce 0
[iyunv@slave etc]# getenforce
Permissive
【注意:】因为我们从主服务器上抓取文件到 slaves 这个目录下是由 named 这个系统用户来完成的,所以我们要保证slaves要有可写权限,同时slaves的所属用户、所属组都是 named