当前位置: 主页 > 服务器技术 > DNS服务器 > bind配置指南

bind配置指南

时间:2010-3-12来源:互联网 点击:

    一.、Bind 简介。
  Bind是一款开放源码的DNS服务器软件,Bind由美国加州大学Berkeley分校开发和维护的,全名为Berkeley Internet Name Domain它是目前世界上使用最为广泛的DNS服务器软件,支持各种unix平台和windows平台。本文将介绍它在Red hat Linux 9中最基本的安装和配置。

二.、软件的相关资源。
官方网站:http://www.bind.com/

源码软件包:Bind 是开源的软件,可以去其官方网站下载。http://www.isc.org/index.pl/sw/bind/ ,目前最新版本为bind-9.3.1。

帮助文档:http://www.isc.org/index.pl/sw/bind/ 有该软件比较全面的帮助文档。

FAQ:http://www.isc.org/index.pl/sw/bind/ 回答了该软件的常见问题。

配置文件样例:http://www.bind.com/bind.html 一些比较标准的配置文件样例。

三.、软件的安装。
1.安装

由其官方网站中下载其源码软件包bind-9.3.1. tar.gz。接下来我将对安装过程的一些重要步骤,给出其解释:

[root@localhost root]#tar xzvf bind-9.3.1. tar.gz
[root@localhost root]#cd bind-9.3.1
[root@localhost bind-9.3.1]#./configure
[root@localhost bind-9.3.1]#make
[root@localhost bind-9.3.1]#make install

tar xzvf bind-9.3.1.tar.gz 解压缩软件包。

./configure 针对机器作安装的检查和设置,大部分的工作是由机器自动完成的,但是用户可以通过一些参数来完成一定的设置,其常用选项有:

./configure --help 察看参数设置帮助。

--prefix= 指定软件安装目录(默认/usr/local/)。

--enable-ipv6 支持ipv6。

可以设置的参数很多,可以通过 -help察看需要的,一般情况下,默认设置就可以了。

默认情况下,安装过程是不会建立配置文件和一些默认的域名解析的,不过并不妨碍,可以从下载一些标准的配置文件(http://www.bind.com/bind.html),也可以使用本文所提供的样例文件。

默认情况下,安装的deamon为/usr/local/sbin/named

默认的主配置文件,/etc/named.conf(须手动建立)。

2.启动:

[root@localhost root]# /usr/local/sbin/named -g

/usr/local/sbin/named默认情况是一个后台deamon ,-g选项表示前台运行,并将调试信息打印到标准输出,这在我们安装调试阶段是非常有帮助的。

如果建立了配置文件和域名解析文件(关于怎样建立将在下面的部分讲到),ps aux 应该可以查到named 的进程,或netstat -an 也可以看到53端口的服务已经起来了。(DNS默认端口为53)

如果要设置开机自启动DNS server,只需在/etc/rc.d/rc.local中加入一行

/usr/local/sbin/named

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don‘t
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local

/usr/local/sbin/named

四.软件的配置。
1.主配置文件

默认安装主配置文件的位置为

/etc/named.conf

下面逐步分析一个比较基础的配置文件:(注:named配置文件采用和c语言相同的注释符号)。

(1) log options

/*
* log option
*/
logging {
channel default_syslog { syslog local2; severity error; };
channel audit_log { file "/var/log/named.log"; severity error; print-time yes; };
category default { default_syslog; };
category general { default_syslog; };
category security { audit_log; default_syslog; };
category config { default_syslog; };
category resolver { audit_log; };
category xfer-in { audit_log; };
category xfer-out { audit_log; };
category notify { audit_log; };
category client { audit_log; };
category network { audit_log; };
category update { audit_log; };
category queries { audit_log; };
category lame-servers { audit_log; };
};

这一部分是日志的设置,其中最主要的是

file "/var/log/named.log" 这一句指定了日志文件的位置,要正常启动named,必须要保证这一文件是存在的,并且named 进程对它有读写权限。

(2) options

options {
directory "/etc/namedb";

listen-on-v6 { any; };

// If you‘ve got a DNS server around at your upstream provider, enter
// its IP address here, and enable the line below. This will make you
// benefit from its cache, thus reduce overall DNS traffic in the Internet.

forwarders {
your.upper.DNS.address;
};

/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;

/*
* If running in a sandbox, you may have to specify a different
* location for the dumpfile.
*/
dump-file "/etc/named_dump.db";
};

这一部分是一些基本的配置项:

directory "/etc/namedb"; 指定域名解析等文件的存放目录(须手动建立);

listen-on-v6 { any; }; 支持ipv6的请求;

forwarders {

your.upper.DNS.address;

}; 指定前向DNS,当本机无法解析的域名,就会被转发至前向DNS进行解析。

dump-file "/etc/named_dump.db"; 指定named_dump.db文件的位置。

(3) 线索域和回环域

// Setting up secondaries is way easier and the rough picture for this
// is explained below.
//
// If you enable a local name server, don‘t forget to enter 127.0.0.1
// into your /etc/resolv.conf so this server will be queried first.
// Also, make sure to enable it in /etc/rc.conf.

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

zone "0.0.127.IN-ADDR.ARPA" {
type master;
file "localhost.rev";
};

指定线索域和本地回环域,这一部分使用一些标准的例子就可以。

file "named.root"; 指定该域的解析文件,其目录为options中directory "/etc/namedb";指定的。在本例中为/etc/namdb。

 

站长资讯网
.
分页: [1] [2]
TAG: bind 配置
推荐内容最近更新人气排行
关于我们 | 友情链接 | 网址推荐 | 常用资讯 | 网站地图 | RSS | 留言