Chinaunix首页 | 论坛 | 博客
  • 博客访问: 84576
  • 博文数量: 41
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 490
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-24 09:19
文章分类

全部博文(41)

文章存档

2011年(1)

2010年(4)

2009年(36)

我的朋友

分类: LINUX

2009-08-27 13:54:05

先从 下载bind,我下载的是bind-9.3.2.tar.gz

我下载的文件放在/root目录下
进入目录解压缩
[root@linux root]#tar xfz bind-9.3.2.tar.gz
进如刚解压出来的目录
[root@linux root]# cd bind-9.3.2
编译配置
[root@linux bind-9.3.2]#./configure --prefix=/usr/local/named --enable-threads #--enable-threads
开启多线程处理能力
[root@linux bind-9.3.2]#make
[root@linux bind-9.3.2]#make install
进入/usr/local/named 建立etc目录
[root@linux bind-9.3.1rc1]#cd /usr/local/named
[root@linux named]# mkdir etc
生成rndc控制命令的key文件
[root@linux named]# sbin/rndc-confgen >; etc/rndc.conf

(注:在AS4下面,“;”应该去掉)
rndc.conf文件中提取named.conf用的key
root@linux named]# cd etc
[root@linux etc]# tail -10 rndc.conf | head -9 | sed s/#\ //g >
named.conf

(注:在AS4下面,“;”应该去掉)
自动在/usr/local/named/etc 生成named.conf文件
建立区文件目录
[root@linux etc]# mkdir /var/named
进入/var/named
[root@linux etc]# cd /var/named
建立localhost.zone文件
[root@linux named]#vi localhost.zone
$TTL    86400
$ORIGIN localhost.
@                       1D IN SOA       @ root (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum

                        1D IN NS        @
                        1D IN A         127.0.0.1


建立named.local文件
[root@linux named]#vi named.local
$TTL    86400
@       IN      SOA     localhost. root.localhost.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
              IN      NS      localhost.

1       IN      PTR     localhost.


dig
命令直接生成named.root文件
[root@linux named]#dig >; named.root

试了一下但生成的文件里面什么也没有,这个文件可以从这里下载:

ftp://ftp.rs.internic.net/domain/named.root
建立test.com域名正向解析文件
[root@linux named]#vi test.zone

$TTL    1D
@               IN SOA  test.com.  root.test.com. (

                                       1053891162
                                        3H
                                        15M
                                        1W
                                        1D )

                        IN NS          test.com.
                        IN MX    5    test.com.
www                IN A         192.168.0.20
ftp                IN A         172.16.1.46
sunground          IN A         172.16.1.50


建立test.com域名反向解析文件
[root@linux named]#vi test.local
$TTL 86400
@ IN SOA test.com. root.test.com.(
20031001;
7200;
3600;
43200;
86400);
@ IN NS test.com.
20 IN PTR .

 

建立test.com域名正向解析文件
[root@linux named]#vi sunground.zone

$TTL    1D
@               IN SOA  sunground.com.  root.sunground.com. (

                                       1053891162
                                        3H
                                        15M
                                        1W
                                        1D )

                        IN NS          sunground.com.
                        IN MX    5    sunground.com.
www                IN A         172.16.0.20
ftp                IN A         172.16.1.99
sunground          IN A         172.16.1.100

 

建立test.com域名反向解析文件
[root@linux named]#vi sunground.local
$TTL 86400
@ IN SOA sunground.com. root.sunground.com.(
20031001;
7200;
3600;
43200;
86400);
@ IN NS sunground.com.
20 IN PTR dns.sunground.com.



配置named.conf加如以下代码

[root@linux etc]# vi named.conf

key "rndc-key" {
        algorithm hmac-md5;
        secret "MNFgcMSW1azcRiOh4bQ2pQ==";
};

controls {
        inet 127.0.0.1 port 953
                allow { 127.0.0.1; } keys { "rndc-key"; };
};

options {
directory "/opt/named/var/named";
         recursion yes;
         forward only;
         forwarders {
                 202.106.0.20;
                 202.106.46.151;
         };
};

logging {
         channel my_file {
                          file "/opt/named/log/namedlog";
                          severity debug 1;
                          print-time yes;
                          };
         category queries { my_file; };
         category statistics { my_file; };
         category xfer-in { my_file; };
         category xfer-out { my_file; };
};

zone "." IN {
        type hint;
        file "named.root";
};

zone "localhost" IN {
        type master;
        file "localhost.zone";
        allow-update { none; };
};

zone "0.0.127.in-addr.arpa" IN {
        type master;
        file "named.local";
        allow-update { none; };
};

zone "test.com" IN {
        type master;
        file "test.zone";
        allow-update { none; };
};


zone "0.168.192.in-addr.arpa" IN {
        type master;
        file "test.local";
        allow-update { none; };
};


zone "sunground.com" IN {
        type master;
        file "sunground.zone";
        allow-update { none; };
};


zone "0.16.172.in-addr.arpa" IN {
        type master;
        file "sunground.local";
        allow-update { none; };
};



现在配置完了可以启动BIND

/usr/local/named/sbin/named -c /usr/local/named/etc/named.conf &

只要显示
runing
表示运行成功
测试DNS
[root@linux etc]# host 192.168.0.20
20.0.168.192.in-addr.arpa domain name pointer dns.test.com.
如上显示表示DNS反向解析正常
[root@linux etc]# ping
PING (192.168.0.20) 56(84) bytes of data.
如上显示表示正向解析正常

更改配置文件让配置生效

killall -HUP named

DNS配置完成。

 

 

 

 

 

named.root文件

 

;       This file holds the information on root name servers needed to
;       initialize cache of Internet domain name servers
;       (e.g. reference this file in the "cache  .  "
;       configuration file of BIND domain name servers).
;
;       This file is made available by InterNIC 
;       under anonymous FTP as
;           file                /domain/named.root
;           on server           FTP.INTERNIC.NET
;       -OR-                    RS.INTERNIC.NET
;
;       last update:    Jan 29, 2004
;       related version of root zone:   2004012900
;
;
; formerly NS.INTERNIC.NET
;
.                        3600000  IN  NS    A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET.      3600000      A     198.41.0.4
;
; formerly NS1.ISI.EDU
;
.                        3600000      NS    B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET.      3600000      A     192.228.79.201
;
; formerly C.PSI.NET
;
.                        3600000      NS    C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET.      3600000      A     192.33.4.12
;
; formerly TERP.UMD.EDU
;
.                        3600000      NS    D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET.      3600000      A     128.8.10.90
;
; formerly NS.NASA.GOV
;
.                        3600000      NS    E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET.      3600000      A     192.203.230.10
;
; formerly NS.ISC.ORG
;
.                        3600000      NS    F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET.      3600000      A     192.5.5.241
;
; formerly NS.NIC.DDN.MIL
;
.                        3600000      NS    G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET.      3600000      A     192.112.36.4
;
; formerly AOS.ARL.ARMY.MIL
;
.                        3600000      NS    H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET.      3600000      A     128.63.2.53
;
; formerly NIC.NORDU.NET
;
.                        3600000      NS    I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET.      3600000      A     192.36.148.17
;
; operated by VeriSign, Inc.
;
.                        3600000      NS    J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET.      3600000      A     192.58.128.30
;
; operated by RIPE NCC
;
.                        3600000      NS    K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET.      3600000      A     193.0.14.129 
;
; operated by ICANN
;
.                        3600000      NS    L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET.      3600000      A     198.32.64.12
;
; operated by WIDE
;
.                        3600000      NS    M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET.      3600000      A     202.12.27.33
; End of File

 

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