rehhat5.5搭建各种dns服务器(1)

项目一:域名系统集成

( Domain Name System Integration )

1.1  搭建缓存服务器

1.2  搭建正向服务器

1.3  搭建主从DNS服务器

1.4  利用TSIG数字签名技术加固DNS服务

1.5  子域授权

1.6  转发服务器

1.7  利用rndc远程控制DNS

 

 

 

第一阶段

项目内容:

搭建最基本的正向解析DNS服务器,满足最基本的DNS服务器配置

 

项目目的:

第一阶段的目的就是让你首先了解DNS server的目录结构和配置文件最基本配置,了解如何声明一个自己的域,以及了解与文件的书写格式。为后面配置更多功能的DNS服务器做好准备工作

 

步骤:

1、  安装必要软件

[root@Dns_master /]# yum install bind bind-chroot caching-nameserver –y

….

Installed:

  bind.i386 30:9.3.6-4.P1.el5_4.2

  bind-chroot.i386 30:9.3.6-4.P1.el5_4.2

  caching-nameserver.i386 30:9.3.6-4.P1.el5_4.2

2、  配置

 

1)修改主配置文件

[root@Dns_master /]# cd /var/named/chroot/

[root@Dns_master chroot]# pwd

/var/named/chroot

[root@Dns_master chroot]# ls

dev  etc  var

[root@Dns_master chroot]# cd etc/

[root@Dns_master etc]# ls

localtime  named.caching-nameserver.conf  named.rfc1912.zones  rndc.key

[root@Dns_master etc]# vi named.caching-nameserver.conf

 

为了简化配置,将下面几项改成any

# grep  "any" named.caching-nameserver.conf

        listen-on port 53   { any; };             #监听端口

        allow-query       { any; };             #查询地址

        match-clients      { any; };             #客户端

        match-destinations { any; };           #查询目的地址

 

2)声明一个域

[root@Dns_master etc]# pwd

/var/named/chroot/etc

[root@Dns_master etc]# ls

localtime  named.caching-nameserver.conf  named.rfc1912.zones  rndc.key

[root@Dns_master etc]# vi named.rfc1912.zones

[root@Dns_master etc]# tail -5 named.rfc1912.zones

zone "Skylinux.com" IN {

        type master;

        file "Skylinux.com.zone";

        allow-update { none; };

};

[root@Dns_master etc]#

 

3)建立对应的正解区域文件

[root@Dns_master etc]# cd ../var/named/

[root@Dns_master named]# pwd

/var/named/chroot/var/named

[root@Dns_master named]# ls

data              localhost.zone   named.ca         named.local  slaves

localdomain.zone  named.broadcast  named.ip6.local  named.zero

[root@Dns_master named]#

[root@Dns_master named]# cat Skylinux.com.zone

$TTL    86400

@               IN SOA  @       root (

                                        42              ; serial (d. adams)

                                        3H              ; refresh

                                        15M             ; retry

                                        1W              ; expiry

                                        1D )            ; minimum

 

                IN NS           dns.Skylinux.com.

www             IN A            192.168.1.100

 

[root@Dns_master named]#

 

4)修改区域文件的权限

[root@Dns_master named]# chown :named Skylinux.com.zone

 

5检查配置文件语法

[root@Dns_master named]# named-checkconf   ###检测配置文件是否有语法错误

[root@Dns_master named]# named-checkzone  Skylinux.com  Skylinux.com.zone

zone Skylinux/IN: loaded serial 42

OK

[root@Dns_master named]#

 

3、重新启动named服务

[root@Dns_master named]# service named restart

停止 named                                               [确定]

启动 named                                               [确定]

[root@Dns_master named]#

 

4、测试

首先添加DNS服务器记录

[root@Dns_master named]# vim /etc/resolv.conf

[root@Dns_master named]# cat /etc/resolv.conf

nameserver 192.168.1.100

[root@Dns_master named]#

[root@Dns_master named]# host www.Skylinux.com

www.Skylinux.com has address 192.168.1.100

[root@Dns_master named]# ping www.Skylinux.com

PING www.Skylinux.com (192.168.1.100) 56(84) bytes of data.

64 bytes from Dns_master (192.168.1.100): icmp_seq=1 ttl=64 time=0.017 ms

64 bytes from Dns_master (192.168.1.100): icmp_seq=2 ttl=64 time=0.013 ms

 

说明搭建成功。

 

第二阶段

项目内容:搭建主从正向DNS服务器,也叫主辅DNS服务器,就是slave可以为master分担请求。

 

项目目的:

第一、从服务器分担主服务器的查询请求。
第二、可以多地域多运营商部署N台从服务器,让更多的用户查询请求能够更快的响应。
第三、主服务器挂了,从服务器一样可以正常响应DNS查询请求。

项目环境:

主机(masterip192.168.1.100/24

从机(slaveip1921.68.1.103/24

 

步骤:

1、  在主机和从机都安装必备软件

# yum install bind bind-chroot caching-nameserver –y

并将主配置文件的几个地方改成any

2、  配置

1)  Master端配置

 

修改域声明配置文件

[root@Dns_master etc]# pwd

/var/named/chroot/etc

[root@Dns_master etc]# ls

localtime  named.caching-nameserver.conf  named.rfc1912.zones  rndc.key

[root@Dns_master etc]# vi named.rfc1912.zones

[root@Dns_master etc]# tail -5 named.rfc1912.zones

        type master;

        file "Skylinux.com.zone";

        allow-transfer{192.168.1.103};

              notify yes

};

 [root@Dns_master etc]#

 

修改Masterzone文件加入slaveNS

[root@Dns_master etc]# cd ../var/named/

[root@Dns_master named]# vi Skylinux.com.zone

[root@Dns_master named]# cat Skylinux.com.zone

$TTL    86400

@               IN SOA  @       root (

                                        42              ; serial (d. adams)

                                        3H              ; refresh

                                        15M             ; retry

                                        1W              ; expiry

                                        1D )            ; minimum

 

                IN NS           dns.Skylinux.com.

                IN NS           dns2.Skylinux.com.

                IN A            192.168.1.100

              IN A            192.168.1.103

 [root@Dns_master named]#

注:如不修改则只能向从机传递zone文件 从机不会随主机更新正解反解文件而更新

 

Slave端配置

[root@Dns_master named]# ssh 192.168.1.103

The authenticity of host '192.168.1.103 (192.168.1.103)' can't be established.

RSA key fingerprint is d3:ef:f8:d2:75:4c:86:9f:1e:b9:09:3e:96:19:b0:d8.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.1.103' (RSA) to the list of known hosts.

[email protected]'s password:

Last login: Sun Sep  4 22:27:17 2011 from 192.168.100.203

[root@Dns_slave ~]#

 

修改域声明文件

[root@Dns_slave etc]# pwd

/var/named/chroot/etc

[root@Dns_slave etc]# vi named.rfc1912.zones

[root@Dns_slave etc]# tail -6 named.rfc1912.zones

zone "Skylinux.com" IN {

        type slave;

        file "slaves/Skylinux.com.zone";

        masters {192.168.1.100;};

};

 

[root@Dns_slave etc]#

[root@Dns_slave etc]#

3、测试

重新启动主从两台服务器,zone文件会自动复制过去

[root@Dns_master named]# service named restart

停止 named                                               [确定]

启动 named                                               [确定]

[root@Dns_master named]#

 

[root@Dns_slave etc]# service named restart

停止 named                                               [确定]

启动 named                                               [确定]

[root@Dns_slave etc]#

[root@Dns_slave etc]# cd ../var/named/slaves/

[root@Dns_slave slaves]# ls

Skylinux.com.zone

[root@Dns_slave slaves]# pwd

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

[root@Dns_slave slaves]#

[root@Dns_slave slaves]# cat Skylinux.com.zone

$ORIGIN .

$TTL 86400      ; 1 day

Skylinux.com        IN SOA  Skylinux.com. root.Skylinux.com. (

                                42         ; serial

                                10800      ; refresh (3 hours)

                                900        ; retry (15 minutes)

                                604800     ; expire (1 week)

                                86400      ; minimum (1 day)

                                )

                        NS      dns.Skylinux.com.

                        A       192.168.1.103

[root@Dns_slave slaves]#

 

再向主服务器中添加新的正反记录并修改版本号,重新启动master端后,slave端即可更新记录。

 

[root@Dns_master named]# vi Skylinux.com.zone

[root@Dns_master named]# cat Skylinux.com.zone

$TTL    86400

@               IN SOA  @       root (

                                        43              ; serial (d. adams)

                                        3H              ; refresh

                                        15M             ; retry

                                        1W              ; expiry

                                        1D )            ; minimum

 

                IN NS           dns.Skylinux.com.

                IN A            192.168.1.103

www             IN A            192.168.1.100

 

[root@Dns_master named]#

 

 

注:如果更新完Master之后,Slave端迟迟不更新是什么原因呢?

原因一:更新记录之后,没有及时的更改版本号

原因二:服务器端域声明文件中没打开notify yes 选项,SOArefresh 数值太大

原因三:以上问题都不存在,那可能就是masterslave两台服务器的系统时间不一致,两台机器的系统时间保持相差在2分钟之内,否则也会造成更新慢或者不更新。

你可能感兴趣的:(redhat,职场,休闲,DNS服务器)