Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2783283
  • 博文数量: 423
  • 博客积分: 7770
  • 博客等级: 少将
  • 技术积分: 4766
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-09 11:58
个人简介

Oracle/DB2/Postgresql/Mysql/Hadoop/Greenplum/Postgres-xl/Mongodb

文章分类

全部博文(423)

文章存档

2019年(3)

2018年(6)

2017年(27)

2016年(23)

2015年(30)

2014年(16)

2013年(31)

2012年(73)

2011年(45)

2010年(14)

2009年(30)

2008年(30)

2007年(63)

2006年(32)

分类: LINUX

2007-04-19 10:45:03

**********转贴时请保留一下内容******************

RHCEDNS配置详解

本文以Red Hat Enterprise Linux AS v4为平台,

chroot模式下配置,其它版本略有不同,若在实验

中碰到问题,请跟帖,我会尽力帮助解决问题,望大家共

同探讨,研究,学习.请提出宝贵意见

Mail

博客:http://linuxsos.cublog.cn

冯志亮

2007-4-5

**************************************************

    所需配置文件

1.  Red Hat Enterprise Linux 光盘(第一、四张)

2.  /var/named/chroot/etc/named.conf                                        //DNS主配置文件,无需配置

3.  /etc/host.conf                                                                           //转换程序控制文件,系统自带无需配置

4.  /etc/resolv.conf                                                                        //转换程序配置文件,系统自带需配置

5.  /var/named/chroot/var/named/named.ca                                // 根域名服务器指向文件,无需配置

6.  /var/named/chroot/var/named/localhost.zone  localhost    //正向区文件,默认存在,无需配置

7.  /var/named/chroot/var/named/named.local  localhost         //反向区文件,默认存在,无需配置

8.  /var/named/chroot/var/named/feng86.zone                          //用户配置正向区文件,默认不存在,需自己创建并且配置

9.  /var/named/chroot/var/named/0.168.192.zone                      //用户配置反向区文件,默认不存在,需自己创建并且配置

    配置过程详解

1.  安装DNS

 #rpm –qa |grep bind                                                                  //查看是否安装bind

 #mount /media/cdrom                                                                //挂载光盘第四张

                     cd /media/cdrom/RedHat/RPMS                                           //进入光盘目录

 #rpm –ivh bind-9.2.4-16.EL4.i386.rmp                                    //安装所需的RPM

                     rpm –ivh bind-chroot-9.2.4-16.EL4.i386.rmp                         //安装所需的RPM

                     rpm –ivh bind-devel-9.2.4-16.EL4.i386.rmp                           //安装所需的RPM

                     cd;eject                                                                                       //弹出光盘

    mount /media/cdrom                                                                //挂载光盘第一张

                     cd /media/cdrom/RedHat/RPMS                                            //进入光盘目录    

           rpm –ivh caching-nameserver-7.3-3.noarch.rpm                 //安装所需的RPM

                      cd;eject                                                                                   //弹出光盘

2.  配置主域名服务器 feng86.com

A/var/named/chroot/etc/named.conf  ,DNS主要配置文件,设置一般的named参数,信息源,对该文件的操作是添加区域。在主配置文件中添加区声明,

vi /var/named/chroot/etc/named.conf  //内容如下:

 options {                                                                                      //定义全局配置选项

                                      directory  “/var/named”;                                             //定义服务器区配置文件的工作目录

                                      dump-file  “/var/named/data/cache_dump.db”;

                                       statistics-file “/var/named/data/named_stats.txt”;

                                         };

     controls {                             //定义rndc命令使用的控制通道,rndcbind9服务器控制使用程序

                  inet 127.0.0.1 allow {localhost;} keys{rndckey;};

                      }

 

       zone “.”IN {                                                              //表示这一小节将定义根(.)区域

             type hint;                                                          //指定类型为hint,启动时初始化高速缓存的域名服务器

             file “named.ca”                                                 //包含该区域的根文件

       };

       zone “localdomain” IN {  

              type master;

              file “ localdomain.zone”;

              allow-updata { none; };

        };

        zone “localhost” IN {                                                                                  //定义localhost的正向解析区域

              type master;                                                                                         //指定为master,即主域名服务器

              file “ locahost.zone”;                                                                        //包含该区域的文件为locahost.zone

              allow-updata { none; };

        };

zone “0.0.127.in-addr.arpa” IN {                                           //定义localhost的反向解析区域

              type master;                                                                                        //指定为master,即主域名服务器

              file “ named.local”;                                                                            //包含该区域的文件为named.local

              allow-updata { none; };

        };

        zone “feng86.com” IN {                                                                            //定义feng86.com的正向解析区域

              type master;                                                                                           //指定为master,即主域名服务器

              file “ feng86.zone”;                                                                            //包含该区域的文件为feng86.zone

              allow-updata { none; };

        };

        zone “0.168.192.in-addr.arpa” IN {                                                             //定义feng86.com的反向区域

              type master;                                                                                           //指定为master,即主域名服务器

              file “ 0.168.192.zone”;                                                                          //包含该区域的文件为0.168.192.zone

              allow-updata { none; };

        };

Include “/etc/rndc.key”;                                                                                   //包含文件

 

B.建立正()向解析的数据库文件

cd /var/namd/chroot/var/named                                                                 //进入目录

cp localhost.zone feng86.zone                                                                   //建立正向解析的数据库文件feng86.zone

cp named.local  0.168.192.zone                                                                     //建立反向解析的数据库文件0.168.192.zone

C.配置正()向解析的数据库文件

 1.配置正向数据库文件,即实现域名到IP的对应。

cd /var/namd/chroot/var/named                                                              //进入目录

     vi feng86.zone                                                                                             //编辑feng86.zone

   $TTL   86400                                                                                                      // 授权区域信息的时间长度(s),默认一天

   @     IN   SOA  dns.feng86.com. root.dns.feng86.com.(                             //创建授权起始记录

42                                                                                     // 日期标记 格式为yyyymmdd##

3H                                                                                     //3小时

15M                                                                                 //15分钟

1W                                                                                    //1

1D )                                                                                   //1

 

feng86.com.    IN    NS  dns.feng86.com.                                                           //设置域名服务记录

dns          IN     A   192.168.0.11                                                                            //dns地址记录

www         IN     A   192.168.0.10                                                                           //www地址记录

ftp           IN     A   192.168.0.200                                                                            //ftp地址记录

mail          IN     A   192.168.0.100                                                                          //mail地址记录

web          IN    CNAME   192.168.0.11                                                                 //别名记录

2. .配置反向数据库文件,即实现IP到域名的映射

cd /var/namd/chroot/var/named                                                                  //进入目录

     vi  0.168.192.zone                                                                                              //编辑0.168.192.zone

   $TTL   86400                                                                                                           // 授权区域信息的时间长度(s),默认一天

   @     IN   SOA  dns.feng86.com. root.dns.feng86.com.(                                  //创建授权起始记录

1997022700   

28800

14400

3600000

86400 )

IN    NS  dns.feng86.com.       //设置域名服务记

11        IN     PTR   dns.feng86.com                                                                                //dns反向地址指针记录

10        IN     PTR                                                                                //www反向地址指针记录

200       IN     PTR  ftp.feng86.com                                                                                //ftp反向地址指针记录

100       IN     PTR   mail.feng86.com                                                                             //mail反向地址指针记录

 

D.转换程序配置文件(/etc/resolv.conf)

vi /etc/resolv.conf

search feng86.com                                                               //定义域名搜索表(最多6)

nameserver 192.168.0.11                                                   //列出DNS serverIP地址(最多可出现3nameserver)

三、启动DNS

        #service named start   //启动DNS

#service named stop    //停止DNS

#service named restart  //重启DNS

 

  rndc reload   //加载配置文件 

四、测试DNS

A:用nslookup 如:

nslookup       

   >dns.feng86.com

   >

   >ftp.feng86.com

  B:用hostg

      host dns.feng86.com

      host 192.168.0.100

  C:用dig

       dig mail.feng86.com

      dig 192.168.0.100

      dig 192.168.0.200

五、故障排除方法

  1、日志文件查看故障

cd /var/log

echo “”>messages       //清空日志文件

重启DNS服务

more messages |grep named  //查看named的相关信息

 

六、相关命令

           netstat –an  

netstat –a|more
named-checkconf 

named-checkzone

service network restart
ping
pwd
ps
ps -e

注意:配置文件中有好多.(),看清楚别省略了,否则会出现问题。

--------------

阅读(1329) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~