nello 发表于 2007-9-19 08:38

【原创】教你搭建Bind DNS-第一篇-简单搭建你的DNS服务器

注:原创文章,转贴请注目作者nello

系统:Redhat Linux 企业版
Bind版本:bind-9.4.1-P1
目的:搭建一台DNS

1.下载最新版的Bind ,现在最新稳定版为bind-9.4.1-P1.tar.gz :http://www.isc.org/   假定存放路径:/usr/local/scr
#wget http://ftp.isc.org/isc/bind9/9.4.1-P1/bind-9.4.1-P1.tar.gz

[ Edited by nello on 2007-9-19 08:41 ]

nello 发表于 2007-9-19 08:39

2.安装:
#cd /usr/local/src
#tar xzcf bind-9.4.1-P1.tar.gz
#cd bind-9.4.1-P1
#./configure –prefix=/usr/local/dns
#make
#make install

nello 发表于 2007-9-19 08:39

3.配置:配置文件包括-----db.127.0.0,db.192.168.1,db.cache,db.domain,named.conf,rndc.conf
配置文件存放路径:/usr/local/dns/etc

nello 发表于 2007-9-19 08:39

(1)配置rndc.conf
#/usr/local/dns/sbin/rndc-confgen > /usr/local/dns/etc/rndc.conf
自动生成rndc.conf,内容如下:
# Start of rndc.conf
key "rndc-key" {
      algorithm hmac-md5;
      secret "******";
};

options {
      default-key "rndc-key";
      default-server 127.0.0.1;
      default-port 953;
};
# End of rndc.conf

# Use with the following in named.conf, adjusting the allow list as needed:
# key "rndc-key" {
#         algorithm hmac-md5;
#         secret "******";
# };
#
# controls {
#         inet 127.0.0.1 port 953
#               allow { 127.0.0.1; } keys { "rndc-key"; };
# };
# End of named.conf

nello 发表于 2007-9-19 08:39

(2)配置named.conf
#vi /usr/local/dns/etc/named.conf

options {
      directory "/usr/local/dns/etc";
};

zone "." in {
      type hint;
      file "db.cache";
};

zone "0.0.127.in-addr.arpa" in {
      type master;
      file "db.127.0.0";
};

zone "domain.cn" in {
      type master;
      file "db.domain";
};

zone "1.168.192.in-addr.arpa" in {
      type master;
      file "db.192.168.1";
};

// rndc.conf生成
key "rndc-key" {
      algorithm hmac-md5;
      secret "******";
};

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

nello 发表于 2007-9-19 08:39

(3)配置db.cache
#wget ftp://ftp.internic.org/domain/named.root
下载到/usr/local/dns/etc目录,并改名为db.cache。

nello 发表于 2007-9-19 08:40

(4)配置db.127.0.0
# vi /usr/local/dns/etc/db.127.0.0

$TTL 3h
0.0.127.in-addr.arpa. IN SOA ns1.domain.cn. nsmaster.domain.cn. (
      2007083001;
      3h;
      1h;
      1w;
      1h);

0.0.127.in-addr.arpa. IN NS ns1.domain.cn.

1.0.0.127.in-addr.arpa. IN PTR local.

nello 发表于 2007-9-19 08:40

(5)配置db.domain
# vi /usr/local/dns/etc/db.domain

$TTL 3h
domain.cn. IN SOA ns1.domain.cn. nsmaster.domain.cn. (
      2007083001
      3h
      1h
      1w
      1h)
;
;name server
;
domain.cn. IN NS ns1.domain.cn.
;
;address
;
localhost.domain.cn.                IN A 127.0.0.1
ns1.domain.cn.                  IN A         192.168.1.10
www.domain.cn.                        IN A 192.168.1.11
bbs.domian.cn.                        IN A 192.168.1.12
等等,继续添加

nello 发表于 2007-9-19 08:40

(6)配置db.192.168.1
# vi /usr/local/dns/etc/db.192.168.1

$TTL 3h
225.89.211.in-addr.arpa IN SOA ns1.domain.cn. nsmaster.domain.cn. (
      2007083001
      3h
      1h
      1w
      1h)
;
;name server
;
1.168.192.in-addr.arpa. IN NS ns1.domain.cn.
;
;address
;
10.1.168.192.in-addr.arpa. IN PTR ns1.domain.cn.
11.1.168.192.in-addr.arpa. IN PTR www.domain.cn
12.1.168.192.in-addr.arpa. IN PTR bbs.domain.cn
等等,继续添加

nello 发表于 2007-9-19 08:40

4.启动
#cd /usr/local/dns/sbin
#./named –c /usr/local/dns/etc
#./named –g

nello 发表于 2007-9-19 08:40

5.测试
利用nslookup进行测试。
更改配置文件后,可以使用下列命令来刷新配置文件
#cd /usr/local/dns/sbin
#./rndc reload

nello 发表于 2007-9-19 08:40

第一讲到这里结束。

下一讲将向大家介绍细节方面的配置,比如ACL,以及DNS View等等。

winters_ning 发表于 2007-10-2 01:58

不错,不错哦
页: [1]
查看完整版本: 【原创】教你搭建Bind DNS-第一篇-简单搭建你的DNS服务器