一.创建一个DNS域名服务器:(设置域名为zzuwhx.com,服务器主机网卡地址192.168.0.1)
1.)安装DNS服务器必要的rpm安装包(bind,bind-utils,bind-libs)
   yum list all | grep "^bind"
   yum install bind
   yum install bind-utils
   yum install bind-libs
2.)配置DNS服务器的主配置文件/etc/named.conf
  options {
         directory "/var/named";
  };
  zone "." IN {
        type hint;
        file "named.ca";
  };
  zone "localhost" IN {
       type master;
       file "localhost.zone";
  };
  zone "0.0.127.in-addr.arpa" IN {
        type master;
        file "named.local";
  };
  zone "zzuwhx.com" IN {
        type master;
        file "zzuwhx.com.zone";
        allow-transfer { 192.168.0.49; 192.168.0.1; };
        allow-query { 192.168.0.49; 192.168.0.1; };
  };
  zone "0.168.192.in-addr.arpa" IN {
        type master;
        file "192.168.0.zone";
        allow-transfer { 192.168.0.49; 192.168.0.1; };
        allow-query { 192.168.0.49; 192.168.0.1; };
  };
3.)配置DNS服务器的数据文件/var/named/named.ca;连接外网时可直接用命令`dig -t NS . > /var/named/named.ca`或在/var/named/named.ca添加:
  a.root-servers.net.     178562  IN      A       198.41.0.4
  a.root-servers.net.     480559  IN      AAAA    2001:503:ba3e::2:30
  b.root-servers.net.     269418  IN      A       192.228.79.201
  c.root-servers.net.     276759  IN      A       192.33.4.12
  d.root-servers.net.     269451  IN      A       128.8.10.90
  e.root-servers.net.     278224  IN      A       192.203.230.10
  f.root-servers.net.     273127  IN      A       192.5.5.241
  f.root-servers.net.     539590  IN      AAAA    2001:500:2f::f
  g.root-servers.net.     276924  IN      A       192.112.36.4
  h.root-servers.net.     276769  IN      A       128.63.2.53
  h.root-servers.net.     480559  IN      AAAA    2001:500:1::803f:235
  i.root-servers.net.     269381  IN      A       192.36.148.17
  i.root-servers.net.     480559  IN      AAAA    2001:7fe::53
  j.root-servers.net.     269594  IN      A       192.58.128.30
4.)配置DNS服务器的数据文件/var/named/localhost.zone
  $TTL 86400
  @  86400 IN SOA localhost. root.localhost. (
                  2010080301
                  1H
                  10M
                  7D
                  1D )
                  IN  NS   localhost.
  localhost.  IN  A    127.0.0.1
5.)配置DNS服务器的数据文件/var/named/named.local
  $TTL 86400
  @  86400 IN SOA localhost. root.localhost. (
                  2010080301
                  1H
                  10M
                  7D
                  1D )
               IN  NS   localhost.
  1           IN  PTR  localhost.
6.)配置DNS服务器的数据文件/var/named/zzuwhx.com.zone
  $TTL 86400
  $ORIGIN zzuwhx.com.
  @ 86400 IN SOA ns.zzuwhx.com. dnsadmin.zzuwhx.com. (
                    2010080302
                    1H
                    10M
                    7D
                    1D )
     IN   NS   ns
     IN   NS   ns2
     IN   MX  10 mail
     IN   MX  20 pop3
  ns        IN   A   192.168.0.1
  ns2      IN   A   192.168.0.49
  mail     IN   A   192.168.0.151
  pop3   IN   A   192.168.0.152
  www   IN   A   192.168.0.153
  web     IN   CNAME  www
7.)配置DNS服务器的数据文件/var/named/192.168.0.zone
$TTL 86400
  @ 86400 IN SOA ns.zzuwhx.com. dnsadmin.zzuwhx.com. (
                    2010080302
                    1H
                    10M
                    7D
                    1D )
          IN   NS   ns.zzuwhx.com.
          IN   NS   ns2.zzuwhx.com.
  1      IN   PTR  ns.zzuwhx.com.
  49    IN   PTR  ns2.zzuwhx.com.
  151  IN   PTR  mail.zzuwhx.com.
  152  IN   PTR  pop3.zzuwhx.com.
  153  IN   PTR  www.zzuwhx.com.
8.)使用`service named configtest`命令检查语法是否正确,定义/etc/resolv.conf的nameserver为本服务器地址
9.)为主配置文件/etc/named.conf和目录/var/named/内的数据文件赋予其用户组为named
   chgrp named  /etc/named.conf
   chgrp named  /var/named/named.*
   chgrp named  /var/named/localhost.zone
   chgrp named  /var/named/zzuwhx.example.com
   chgrp named  /var/named/192.168.0.zone
10.)启动DNS服务,使用命令`service named start`;若要在以后开机时启动此服务,则要使用`chkconfig named on`命令;DNS服务启后可使用host,dig,nslookup命令来测试DNS服务器

二.创建一个辅助的从DNS服务服务器(从DNS服务器地址192.168.0.49)
1.)安装DNS服务器的软件包(同"一"的步骤1)
2.)配置DNS的主配置文件/etc/named.conf
  options {
        directory "/var/named";
  };
  zone "." IN {
        type hint;
        file "named.ca";
  };
  zone "localhost" IN {
         type master;
         file "localhost.zone";
  };
  zone "0.0.127.in-addr.arpa" IN {
         type master;
         file "named.local";
  };
  zone "zzuwhx.com" IN {
          type slave;
          file "slaves/zzuwhx.com.zone";
          masters { 192.168.0.1; };
          allow-transfer { none; };
  };

  zone "0.168.192.in-addr.arpa" IN {
          type slave;
          file "slaves/192.168.0.zone";
          masters { 192.168.0.1; };
          allow-transfer { none; };
  };

3.)配置DNS的数据文件/var/named/named.ca , /var/named/localhost.zone , /var/named/named.local(同"一"的步骤3,4,5)
4.)使用`service named configtest`命令检查语法是否正确,定义/etc/resolv.conf的nameserver为本服务器地址
5.)为主配置文件/etc/named.conf和目录/var/named/内的数据文件赋予其用户组为named
   chgrp named  /etc/named.conf
   chgrp named  /var/named/named.*
   chgrp named  /var/named/localhost.zone
6.)启动从DNS服务器,使用命令`service named start`;若要在以后开机时可启动此服务,则要使用`chkconfig named on`命令;再重启主DNS服务器,看从DNS服务器的/var/named/slaves/目录下因区域传送得到了两个文件zzuwhx.com.zone和192.168.0.zone
7.)用cat命令看此两文件zzuwhx.com.zone和192.168.0.zone:
  #zzuwhx.com.zone
  $ORIGIN .
  $TTL 86400 ; 1 day
  zzuwhx.com  IN SOA ns.zzuwhx.com. dnsadmin.zzuwhx.com. (
      2010080302 ; serial
      3600       ; refresh (1 hour)
       600        ; retry (10 minutes)
     604800     ; expire (1 week)
     86400      ; minimum (1 day)
      )
   NS ns.zzuwhx.com.
   NS ns2.zzuwhx.com.
   MX 10 mail.zzuwhx.com.
   MX 20 pop3.zzuwhx.com.
  $ORIGIN zzuwhx.com.
  mail    A 192.168.0.151
  ns       A 192.168.0.1
  ns2     A 192.168.0.49
  pop3  A 192.168.0.152
  web   CNAME www
  www  A 192.168.0.153
##################################################################################
  #192.168.0.zone
  $ORIGIN .
  $TTL 86400 ; 1 day
  0.168.192.in-addr.arpa IN SOA ns.zzuwhx.com. dnsadmin.zzuwhx.com. (
    2010080302 ; serial
    3600       ; refresh (1 hour)
    600        ; retry (10 minutes)
    604800     ; expire (1 week)
    86400      ; minimum (1 day)
    )
   NS ns.zzuwhx.com.
         NS ns2.zzuwhx.com.
  $ORIGIN 0.168.192.in-addr.arpa.
  1       PTR ns.zzuwhx.com.
  151   PTR mail.zzuwhx.com.
  152   PTR pop3.zzuwhx.com.
  153   PTR www.zzuwhx.com.
  49   PTR ns2.zzuwhx.com.