Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3694
  • 博文数量: 4
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 60
  • 用 户 组: 普通用户
  • 注册时间: 2013-06-27 15:13
文章分类
文章存档

2013年(4)

我的朋友
最近访客

分类: 其他平台

2013-08-30 13:50:27

DNS实验

DNS实验一

首先安装bind:

执行yum install bind bind-chroot,安装bind,bind-chroot 包

为了方便配置安装caching-nameserver包

yum install caching-nameserver

建议通过yum安装解决依赖关系

切换到/var/named/chroot/etc目录,将

named.caching-nameserver.conf改为默认名称named.conf;

并修改

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image002" border="0" alt="clip_image002" src="" height="153" />

一、配置域名缓冲服务器

1、vi named.conf

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image004" border="0" alt="clip_image004" src="" height="54" />

当前bind服务器对DNS记录的缓存目录是

/var/named/data/cache_dump.db,

注意因为bind运行在chroot环境下,所以实际路径是

/var/named/chroot/var/named/data

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image006" border="0" alt="clip_image006" src="" height="43" />

现在该目录下是空的,因为没有缓存产生。

现在我们开始加入

forward only; 表示该DNS服务器只做缓冲服务器,即使服务器中有zone文件的设置,也不使用。只会将用户发来的查询提交给上一级DNS服务器进行解析或者查看自身缓存中是否有相应的缓冲记录

(注意以;分号结尾)

forwarders {

8.8.8.8;

202.102.134.68;

};

注意forwarders用的是复数格式。转发给谁。

书写大括号时,先写大括号开始和结束,然后在中间添加内容;

这里我们添加google的DNS服务器8.8.8.8以分号结束,再添加一个联通的DNS服务器202.102.134.68备用

做缓存服务器时,为了保证获取相应域名的解析结果,还需要加

recursion参数,这个参数配置当前DNS是否做递归式查询,即当本机DNS服务器搜索不到相应结果时,是否会询问根域做递归式查询。

最终修改

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image008" border="0" alt="clip_image008" src="" height="188" />

注意:bind对配置文件要求很严格,就算是有些地方多了个空格,

服务器都可能启动不了

forward only配置后DNS服务器将只转发不缓存。所以要

配置成真正的DNS缓存服务器,需要删除或注释掉。

这样这台bind服务器就成为一台DNS缓存服务器了。

2、启动bind服务器的方法

1)service启动

service named start

named bind服务器启动脚本名称

start启动服务器;stop关闭服务器

如果不确定这台服务器是否已经在运行,修改之后建议执行restart

重新启动服务,或用reload(内存中重启)

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image010" border="0" alt="clip_image010" src="" height="32" />

2)直接调用服务启动脚本

在/etc/init.d/或者在/initrc.d/目录下的named

/etc/init.d/named start

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image012" border="0" alt="clip_image012" src="" height="23" />

现在我们的DNS服务器就运行起来;

3)执行chkconfig named on设置服务开机启动

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image014" border="0" alt="clip_image014" src="" height="22" />

现在cd /var/named/chroot/var/named/data下产生

了一个named.run文件

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image016" border="0" alt="clip_image016" src="" height="34" />

这个文件记录了DNS服务器的启动信息

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image018" border="0" alt="clip_image018" src="" height="148" />

3、现在我们测试使用这台DNS服务器

1)首先执行vi /etc/resolv.conf,

resolv.conf文件是远程DNS配置文件

hosts文件是本地解析文件

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image020" border="0" alt="clip_image020" src="" height="55" />

在这个文件中我们可以使用 ;分号的方式注释行

将nameserver 8.8.8.8

search localdomain (默认的查询域)两行注释掉

然后添加

nameserver 192.168.1.150(本机IP)

最终修改如图

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image022" border="0" alt="clip_image022" src="" height="48" />

现在我们就设定当前主机使用的DNS服务器是本机服务器。

(2)执行nslookup查询域名

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image024" border="0" alt="clip_image024" src="" height="222" />

exit退出

现在一台DNS缓冲服务器配置成功。

实验二

二、配置Bind正向解析

1、首先编写bind的配置文件,确认路径是/var/named/chroot/etc/。由于关于域的相应配置信息都保存在named.rfc1912.zones这个文件中,这个文件会被named.conf文件include。所以我们可以直接编写named.rfc1912.zones文件。同时该文件有范例可以供参考

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image026" border="0" alt="clip_image026" src="" height="83" />

当type为master时表示当前域的解析是由这台主机做主的。

file 指定这个域的配置文件的位置和名称

allow-update 在使用bind服务器主从的时候用到,控制是否更新域的信息

现在我们添加

zone "test.com" IN {

type master;(表示该域由当前服务器做主DNS解析)

file "test.com.zone";

};

file指定的文件名称习惯上以 “ 域的名称加上.zone结尾 ”, 来表示一个域的配置文件

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image028" border="0" alt="clip_image028" src="" height="70" />

现在当DNS服务器重启后或者reload之后,该服务器将开始test.com的域的解析。

2、vi named.conf修改一下named.conf

将 forward only;

forwarders {

8.8.8.8;

202.102.134.68;

};

注释掉,把我们的配置关闭掉,因为不仅只是做DNS缓存服务器,而是要提供服务。

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image030" border="0" alt="clip_image030" src="" height="86" />

3、重启named服务,因为没有配置test.com.zone文件,所以重启失败

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image032" border="0" alt="clip_image032" src="" height="90" />

现在bind的配置部分已经完成

4、现在bind服务器已经明确需要负责test域的解析,test域中

有哪些记录以及如何解析,这些内容书写在test.com.zone文

件中

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image034" border="0" alt="clip_image034" src="" height="43" />

1)复制并修改zone文件名称

cp localhost.zone test.com.zone

2)检查域名配置文件的权限

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image036" border="0" alt="clip_image036" src="" height="101" />

显示其他的范例文件如localhost.zone

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image038" border="0" alt="clip_image038" src="" height="8" />

拥有者是root,拥有组是named即只有root才能修改,但

named用户是可以读取的。

而test.com.zone文件是我们拷贝然后重命名的文件,权限的拥

有者和拥有组都变成root。这样只有root用户才能读写,named

用户所在的named组是没有权限读取的。

这时named服务器是读不到这个文件。因此如果要让这个文件正

常的被named服务器读取到,需要改变该文件的拥有者

执行chown root.named test.com.zone

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image040" border="0" alt="clip_image040" src="" height="111" />

修改的原因:bind服务器是以named这个普通用户身份来运行的。

如果想让bind服务能够成功正常的读取配置文件,

必须让named用户有读的权限。

注意:不要忘记修改配置文件权限

3)为了方便我们的书写执行,在原有配置基础上书写

vi test.com.zone

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image042" border="0" alt="clip_image042" src="" height="75" />

(1)$TTL 相应解析记录默认生存时间,单位是秒 。表示如果接

下来所写的记录中没有去明确说明一条记录的生存时间的情况下,按照默认的设置来使用。

$TTL是全局定义的

(2)下面这段区域称为SOA记录,这个域名的主管服务器相应的配置信息记录。也就是哪台服务器负责这个域名的解析。

<1>@符号 在bind配置文件中,它的含义比较特殊;代表服

务器本身。在这里表示的就是test.com

<2>SOA后的@符号 表示这个域的名称的主DNS解析服务器

这里写入ns1.test.com.

<3>root 负责管理这台服务器的管理员的email地址。

设置为root表示当前主机的root用户。

完整的名称可以写为

wangjifu_afu.126.com

注意这里添加Email实际地址是

wangjifu_afu@126.com

因为@符号在zone文件中有特殊含义表示域本身,

所以把wangjifu_afu@126.com中的@替换为.

wangjifu_afu后面的.表示@符号

(4)

{ }记录的是当前这个域的各项配置信息

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image044" border="0" alt="clip_image044" src="" height="14" />

serial 编号或者序列号。如果当前有主从服务器,从服务器

通过判断serial number来得知当前域的配置的内

容是否发生了更新,所以每做一次更新,我们应该将

serial number至少加1。

(5)

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image046" border="0" alt="clip_image046" src="" height="70" />

这四个时间戳用来控制从服务器

3H ; refresh

15M ; retry

3H H代表hour,3个小时;

15M M代表minute,15分钟;

refresh 如果有从服务器,从服务器会每隔三个小时连

接一次这台主服务器,查看相应内容是否更新。如果刷

新的时候没有成功连上master服务器,15分钟之后重

新尝试连接,连接失败后反复尝试,每隔15分钟尝试

一次,直到连接成功。

1W ; expiry

W代表week,一周;

如果一周之内都未连接成功,slave服务器会认为

master服务器已经失效,不再进行尝试

1D ) ; minimum

D代表day,一天;

一天至少做一次更新。

如果从服务器频繁停开机,在三个小时的间隔内,无法

达到三个小时的refresh时间,所以至少过了一天,

开机无论过了多长时间,首先更新一次。

注意:这四个时间戳的设置时间受前面的$TTL时间影响,如

果$TTL时间设置比他们短,则以$TTL时间为准。

(6)

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image048" border="0" alt="clip_image048" src="" height="24" />

域名解析的记录。

前面的空白表示同上的意思

这里的上一行是@,这里等于写了test.com.

@表示域本身;空白表示同上

<1>IN NS 记录 解释当前这个域名的名称服务器

test.com. IN NS ns1.test.com.

表示test.com.的名称服务器是ns1.test.com.

注意:大小要写严格区分

<2>A记录部分

ns1.test.com. IN A 192.168.1.150(本机IP)

表示ns1.test.com.的A记录是192.168.1.150

注意前面必须写成FQDN格式(全域名格式),

如ns1.test.com.

3600 IN A 192.168.1.160

3600表示指定这条记录的生存时间为3600秒。这个3600

秒的设置优先于默认的$TTL时间设置。如果我们认为$TTL

默认时间太长,就可以单独指定某条记录的生存时间。

这样无论是从服务器、缓冲的DNS服务器,3600秒之后这

条记录过期,如果需要再次查询,需要重新询问该条记录。

注意:不要将该条记录生存时间设置过短。否则会导致缓

冲服务器频繁查询,浪费资源。

ftp IN A 192.168.1.151

注意:bind配置文件中只写主机名没有.点的情况,会自动加

全域名。

这里相当于ftp.test.com.

如果写成ftp.test.com(.没写)就解释成

ftp.test.com.test.com.

所以,前面要么写FQDN格式,要么使用简写。

<3>CNAME记录部分

a IN CNAME book.test.com.

b IN CNAME book.test.com.

book IN A 192.168.1.152

表示a.test.com.和b.test.com.都指向book.test.com.;

book.test.com.的A记录是192.168.1.152

<4>MX记录

MX记录除了直接写之外,还可以加其他内容。内容为:如果域中有多个邮件服务器,可以指定级别。

如果指定多个邮件服务器,会首先使用数字较少的记录;如果该记录连不上,则会去选择备用的记录。

test.com. IN MX 10 mail1.test.com.

IN MX 20 mail2.test.com.

mail1 IN A 192.168.1.153

mail2 IN A 192.168.1.154

注意MX记录是一个比较特殊的记录:

需要指定域的MX记录是哪台主机,

如test.com.域的第一个MX记录指向他的第一台mail服务器应该是mail1.test.com.;第二台服务器是mail2.test.com.

然后分别写mail1和mail2的A记录

<5> 650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image050" border="0" alt="clip_image050" src="" height="15" />

IPv6的解析记录,目前不需要。删掉即可

最终配置

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image052" border="0" alt="clip_image052" src="" height="128" />

:wq保存退出

5、配置完成,重启服务

service named restart(reload)

执行restart,如果重启失败,可以打印出失败的报错

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image054" border="0" alt="clip_image054" src="" height="23" />

6、执行nslookup查看

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image056" border="0" alt="clip_image056" src="" height="227" />

如果出现错误。查看/etc/resolv.conf文件显示使用的是公网的DNS配置(可能由于计算机重启造成的),修改成使用本机做DNS

注意:必须确保/etc/resolv.conf的配置使用的是

必须是使用本机做DNS服务器,不能使用公网的DNS配置。

7、查看完全信息可以使用dig命令

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image058" border="0" alt="clip_image058" src="" height="180" />

8、查看指定类型

执行nslookup,通过set type=MX命令指定nslookup查看

MX记录

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image060" border="0" alt="clip_image060" src="" height="79" />

显示test.com服务器第一台的是mail1.test.com.;

第二台是mail2.test.com.

查看mail1.test.com

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image062" border="0" alt="clip_image062" src="" height="198" />

如果test.com.域下有个子域nsdomain1.test.com.,

指定domain1.test.com.这个子域的NS服务器nsdomain.test.com.

nsdomain.test.com.的A记录是192.168.1.180(另外一台主机

的IP)

domain1.test.com. IN NS nsdomain.test.com.

nsdomain.test.com. IN A 192.168.1.180

当我们查询domain1.test.com.域的信息时,这台服务器会拒绝;并告知domain1.test.com.的解析服务器是nsdomain.test.com.,同时告知nsdomain.test.com的IP地址是192.168.1.180;

用户将相应请求发到192.168.1.180查询。我们需要再配置子域的域名配置文件。

这样我们就把相应的域按分层的方式分别保存在不同的DNS服务器。

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image064" border="0" alt="clip_image064" src="" height="142" />


实验三

配置Bind反向解析服务器

1、首先进入/var/named/chroot/etc/,执行

vi named.rfc1912.zones编辑

范例:

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image066" border="0" alt="clip_image066" src="" height="65" />

首先写一个zone语句

" " 引号引起网段的配置,网段的顺序为倒叙。

这里可以写"252.16.172.in-addr.arpa" IN

type master;

file "172.16.252.zone";

注意:写反解析的时候不是写某一个IP地址,而是一个网

段的信息。网段的信息要倒过来写。后面加上

.in-addr.arpa字样。

另外.in-addr.arpa,是 - ,不是_下划线。切记!

配置如图

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image068" border="0" alt="clip_image068" src="" height="57" />

2、同样在这里写了zone的配置后,还要到

/var/named/chroot/var/named/

下编辑相应的.zone文件

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image070" border="0" alt="clip_image070" src="" height="36" />

配置如下

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image072" border="0" alt="clip_image072" src="" height="73" />

注意:1是简写格式,表示192.168.1.1,

如果写全称则为1.1.168.192-in.arpa.

所以一般简写。

3、修改权限。切记!!

chown root.named 192.168.1.zone

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image074" border="0" alt="clip_image074" src="" height="119" />

然后执行重新启动服务

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image076" border="0" alt="clip_image076" src="" height="23" />

4、执行nslookup

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image078" border="0" alt="clip_image078" src="" height="107" />

实验四

配置Bind主从服务器

DNS服务器建议两台,一个为master,一个为slave。slave平

时可以不做任何工作,周期性的间隔检查master域名解析的记

录,将master域名的解析记录同步到本机。

这样可以指定一个域有两台DNS服务器解析,一台发生故障,使

用另一台。

1、进入/var/named/chroot/etc/,执行vi named.rfc1912.zones

创建一个新的域,配置如下:

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image080" border="0" alt="clip_image080" src="" height="68" />

2、进入var/named/,执行cp test.com.zone afu.com.zone

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image082" border="0" alt="clip_image082" src="" height="38" />

3、执行set nu 显示一共21行

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image084" border="0" alt="clip_image084" src="" height="149" />

执行:1,21 s/test.com./afu.com./g 将1-21行的test.com.替换为afu.com.

注意:

vi编辑时

s/str1/str2/ 用字符串 str2 替换行中首次出现的字符串 str1  
:s/str1/str2/g 用字符串 str2 替换行中所有出现的字符串 str1    
:s/str1/str2/gi 用字符串 str2 替换行中所有出现的字符串 str1,在查找时不区分大小写

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image086" border="0" alt="clip_image086" src="" height="144" />

子域domain1.afu.com无需配置,删掉该行。

最终配置:

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image088" border="0" alt="clip_image088" src="" height="136" />

先在master服务器上先做一个正向解析记录,然后准备着让slave来同步。

下面配置master服务器,允许slave服务器来进行同步

4、回到/var/named/chroot/etc/目录下,

vi named.rfc1912.zones

现在的master是一个标准的master配置,单个的bind服务器做

域名的解析。现在引入一台slave进行同步设定

在afu.com.这个域的配置中

添加allow-transfer { 192.168.1.180; };

表示只有192.168.1.180这台DNS服务器才能到本机服务器同步afu这个域的相应的内容

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image090" border="0" alt="clip_image090" src="" height="62" />

5、修改权限

进入/var/named/chroot/var/named,

执行chown root.named afu.com.zone

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image092" border="0" alt="clip_image092" src="" height="145" />

执行service named restart重启服务650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image094" border="0" alt="clip_image094" src="" height="23" />

5、然后我们到192.168.1.180这台slave服务器做相应的配置

1)yum install bind bind-chroot

yum install caching-nameserver

2)cd /var/named/chroot/etc/,复制并修改配置文件名称和权限

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image096" border="0" alt="clip_image096" src="" height="136" />

3)vi named.conf

named.conf文件配置和主服务器配置一样

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image098" border="0" alt="clip_image098" src="" height="155" />

4)配置slave部分

vi named.rfc1912.zones

添加

zone "afu.com" IN { 负责解析afu.com这个域

type slave; 这里的type是slave,表示是一个从

级服务器

file "slaves/afu.com.zone" ; slave保存的文件

位置默认保存在

/var/named/chroot/var/named/slaves/

masters { 192.168.1.180; }; master放置的位置。

masters 复数形式,可

以指定多个master

{ }内左右留空格。切记!!括号内由分

号结束;括号外也由分号结束

};

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image100" border="0" alt="clip_image100" src="" height="70" />

表示:

zone语句告诉当前的slave服务器,需要负责解析afu.com.这个域,类型是slave,域的配置文件保存在/var/named/chroot/var/named/slaves/的afu.com.zone,

这个文件是从192.168.1.150这台master服务器获取到的。

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image102" border="0" alt="clip_image102" src="" height="43" />

5)切换到/var/named/chroot/var/named/目录下,

cp localhost.zone afu.com.zone

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image104" border="0" alt="clip_image104" src="" height="103" />

6)查看并修改相关配置文件的权限

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image106" border="0" alt="clip_image106" src="" height="208" />

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image108" border="0" alt="clip_image108" src="" height="56" /> 执行chown root.named named.conf,修改named.conf文件权限。

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image110" border="0" alt="clip_image110" src="" height="56" />

7)执行vi afu.com.zone ,配置如图

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image112" border="0" alt="clip_image112" src="" height="150" />

7)然后执行service named restart

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image114" border="0" alt="clip_image114" src="" height="21" />

查看 /var/named/chroot/var/named/slaves/,

650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;padding-left:0px;padding-right:0px;padding-top:0px;" title="clip_image116" border="0" alt="clip_image116" src="" height="8" />

如果无数据,表示同步出错。执行tail /var/log/messages查看日志。可能是由于防火墙或者selinux的设置造成的。

  • 本稿件为独家原创稿件,版权所有,引用或转载请注明出处。
  • 文章出处:
阅读(301) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~