DNS-BIND安装与配置的关键技术

一.、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。

(4)自定义域

 

zone "test.com" {

type master;

file "zone.test ";

};

 

zone "0.168.192.in-addr.arpa" {

type master;

file "zone. test.rev";

};

zone "4.0.0.f.0.5.2.0.1.0.0.2.IP6.ARPA" {

type master;

allow-transfer { any;};

allow-query { any; };

file "ipv6.rev";

};

 

zone "lowerlevelzone.test.com" {

type slave;

masters {

192.168.1.1;

};

};

 



这一部分是配置文件中我们需要重点关心的部分:

zone "test.com" {

type master;

file "zone.test ";

}; 设定test.com域;

type master 指明该域主要由本机解析;

file "zone.test "指定其解析文件为zong.test,目录为options中设定的目录本例中为/etc/named。

zone "0.168.192.in-addr.arpa" {

type master;

file "zone. test.rev";

}; 指定ipv4地址逆向解析

type master 指明该域主要由本机解析;

file "zone.test.rev "指定其解析文件为zong.test.rev,目录为options中设定的目录本例中为/etc/named。

zone "4.0.0.f.0.5.2.0.1.0.0.2.IP6.ARPA" {

type master;

allow-transfer { any;};

allow-query { any; };

file "ipv6.rev";

};指定ipv4地址逆向解析

type master 指明该域主要由本机解析;

file " ipv6.rev "指定其解析文件为ipv6.rev,目录为options中设定的目录本例中为/etc/named。

zone "lowerlevelzone.test.com" {

type slave;

masters {

192.168.1.1;

};

}; 设定lowerlevelzone.test.com域;

type slave 指明该域主要由低一级的域名服务器解析;

masters {

192.168.1.1;

}; 指定低一级的域名服务器ip地址。

到此我们就初步建立了一个标准的named 的主配置文件,接下来建立对应的域名解析或逆向解析文件。

2.域名解析和IP地址逆向解析文件:

(1) 域名解析:

/etc/namedb/zone.test

 

;	From: @(#)localhost.rev	5.1 (Berkeley) 6/30/90

; $FreeBSD: src/etc/namedb/PROTO.localhost.rev,v 1.6 2000/01/10 15:31:40 peter Exp $

;

; This file is automatically edited by the `make-localhost' script in

; the /etc/namedb directory.

;

@ IN SOA ns.test.com. root.test.com.(

2005030116; Serial

3600 ; Refresh

900 ; Retry

3600000 ; Expire

3600 ) ; Minimum

IN NS ns.test.com

;

 

ns IN A 192.168.0.1

www6 IN AAAA 2001:250:f004::10

www IN A 192.168.0.2

 



本文件前半部分是一些默认的参数设置,只需把域名改成对应得你要设置的域就行,其余的不用过分深究,如果读者有兴趣可以查阅相关的手册文档。

(注意,

IN NS ns.test.com;

这一条必须有,来指定本域的域名服务器 ;

域名必须以"."结尾。)

本文件的第二部分(倒数三行),指定了该域上的主机:

ns IN A 192.168.0.1

ns 为主机名,A 代表地址类型为IPV4地址,192.168.0.1 是实际ip地址,这一条记录的含义是ns.test.com 的ip地址为 192.168.0.1

www6 IN AAAA 2001:250:f004::10

www6 为主机名,AAAA代表地址类型为IPV6地址,2001:250:f004::10 是其IPV6地址,这条记录的含义是www6.test.com 的ip地址是2001:250:f004::10 。

(2)IP地址逆向解析:

ipv4 逆向解析:

/etc/namedb/zone.test.rev

 

;	From: @(#)localhost.rev	5.1 (Berkeley) 6/30/90

; $FreeBSD: src/etc/namedb/PROTO.localhost.rev,v 1.6 2000/01/10 15:31:40 peter Exp $

;

; This file is automatically edited by the `make-localhost' script in

; the /etc/namedb directory.

;

@ IN SOA ns.test.com. root.test.com.(

2005030116; Serial

3600 ; Refresh

900 ; Retry

3600000 ; Expire

3600 ) ; Minimum

IN NS ns.test.com

;

 

1 IN PTR ns.test.com.

2 IN PTR www.test.com.

 



ipv6 逆向解析:

/etc/namedb/zone.test.rev

 

;	From: @(#)localhost.rev	5.1 (Berkeley) 6/30/90

; $FreeBSD: src/etc/namedb/PROTO.localhost.rev,v 1.6 2000/01/10 15:31:40 peter Exp $

;

; This file is automatically edited by the `make-localhost' script in

; the /etc/namedb directory.

;

@ IN SOA ns.test.com. root.test.com.(

2005030116; Serial

3600 ; Refresh

900 ; Retry

3600000 ; Expire

3600 ) ; Minimum

IN NS ns.test.com

;

 

10.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN www6.test.com.

 



这里

10.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN www6.test.com.

与主配置文件/etc/named.conf中的

zone "4.0.0.f.0.5.2.0.1.0.0.2.IP6.ARPA"

"10.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0" + "4.0.0.f.0.5.2.0.1.0.0.2" 刚好组成点分的32位16进制逆序ipv6地址。

实际上,ip地址逆向解析由于缺乏统一的管理和相关的标准,这项服务的使用比较混乱,可以考虑不启动该服务。所以在这里只给出两个例子,就不过多解释了。

五.安装使用的一些经验:

1.带调试信息的启动

named -g

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

2.客户端命令nslookup简介

windows ,linux 平台均支持此调试命令。

键入nslookup即进入与服务器交互状态,这时键入域名或ip地址就可以向服务器正向或逆向查询。

>www.test.com 正向域名解析

>192.168.0.1 逆向IP解析

>set type=AAAA 设置查询地址类型为IPv6地址类型。

>set type=A 设置查询地址类型为IPv4地址类型。

>exit 退出。


参考资料:

[1]:http://www.bind.com/

[2]:http://www.isc.org/index.pl?/sw/bind/

[3]:ipv6.bupt.edu.cn

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值