欢迎光临
我们一直在努力

DNS服务器如何配置

这篇文章将为大家详细讲解有关DNS服务器如何配置,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

BIND9(Solaris 10中的DNS服务器是BIND9)总共需要这些配置文件:

/etc/目录下的文件(这些文件的名字不可更改):

     /etc/named.conf———in.named daemon的配置文件

     /etc/rndc.conf————BIND9必须的配置文件

/etc/named/目录下的文件(这个目录名和文件名均可在/etc/named.conf文件中任意定义):

    named.root

    loop.back

   one.rzone

   one.zone

/*****************named.conf文件的内容***********************/

// This is the /etc/named.boot (boot files) for the primary name server

// of the one.edu. domain.

//
首先定义配置文件的位置:

directory "/etc/named";

//
定义转发器,除了本机定义的域外其他所有请求都发向转发器(非官方授权的DNS服务器基本上都要定义转发器)

forwarders {

        202.101.98.54;

        202.101.98.55;

        };

};

//
接下来指定根DNS服务器的配置文件,此文件可从网络下载:

zone "." in {

        type hint;

        file "named.root";

};

//
本机负责解析的域的正向解析配置文件,此例中为one.edu域,配置文件为one.zone

zone "one.edu" in {

        type master;

        file "one.zone";

};

//
本机负责解析的域的反向解析配置文件,此例中为one.edu域,配置文件为one.zone

zone "1.168.192.in-addr.arpa" in {

        type master;

        file "one.rzone";

};

//环回反向解析配置文件

zone "0.0.127.in-addr.arpa" in {

        type master;

        file "loop.back";

};

//
下面是BIND9专用的配置内容

// Use with the following in named.conf, adjusting the allow list as needed:

// See rndc-confgen command-manual

key "rndc-key" {

       algorithm hmac-md5;

       secret "/cCelQY6sE40JIwQDtXf6g==";

};

controls {

        inet * allow { any; } keys { "rndc-key"; };

};

/*

controls {

       inet 127.0.0.1 port 953

               allow { 127.0.0.1; } keys { "rndc-key"; };

};*/

/*****************rndc.conf文件的内容,可用rndc-confgen命令生成所需内容******************/

key "rndc-key" {

        algorithm hmac-md5;

        secret "/cCelQY6sE40JIwQDtXf6g==";

};

options {

        default-key "rndc-key";

        default-server localhost;

        default-port 953;

};

server localhost {

        key "rndc-key";

};

/*****************/etc/named/目录中的文件****************************/


/********/etc/named/named.root**********/

这个文件内容从网络上下载,不看也罢


/********/etc/named/loop.back**********/

; /var/named/loop.back file for the primary name server.

;

; Start of Authority section

$ORIGIN 0.0.127.IN-ADDR.ARPA.

;

$TTL 8h

; The next line is very long, but is ONE line.

0.0.127.IN-ADDR.ARPA. IN SOA sys11.one.edu. root.sys11.one.edu. (

20011225 ; version number

10800 ; refresh (3hrs.)

3600 ; retry (1hr.)

432000 ; expire (5days)

86400 ) ; ttl (1day)

0.0.127.IN-ADDR.ARPA. IN NS sys11.one.edu.

1 IN PTR localhost.one.edu.



/********/关键是正向解析文件和反向解析文件**********/
/********/etc/named/one.zone **********/


; /var/named/one.zone file for the one.edu. name server
; This file resolves hostnames to IP addresses in the one.edu. domain.
;
$ORIGIN one.edu.
; Time to live (post BIND 8.2) 8 hours
$TTL 8h
one.edu. IN SOA sys11.one.edu. root.sys11.one.edu. (
20011225 ; serial number
10800 ; refresh (3hrs)
3600 ; retry (1hr)
432000 ; expire (5days)
86400 ) ; ttl (1day)
;
; Domain Section
;下面这条意思是one.edu这个域由sys11.one.edu这台主机负责解析
one.edu. IN NS sys11.one.edu.
;
; Host Information Section
; Example; "sys12 IN A 192.168.1.2"
;下面就是主机和IP的对应关系了,sys11 IN A 192.168.1.1就表示sys11.one.edu这个域名的IP为192.168.1.1
sys11 IN A 192.168.1.1
sys12 IN A 192.168.1.2
sys13 IN A 192.168.1.3
sys17 IN A 192.168.1.17
gw IN A 192.168.1.254
xp IN A 192.168.1.11



/********/etc/named/one.rzone **********/

; /var/named/one.rzone file for the one.edu. primary name server
; This file resolves IP addresses to hostnames in the one.edu. domain.
;
$ORIGIN 1.168.192.IN-ADDR.ARPA.
; Time to live (post BIND 8.2) 8 hours
$TTL 8h
1.168.192.IN-ADDR.ARPA. IN SOA sys11.one.edu. root.sys11.one.edu. (
20011225 ; serial number
10800 ; refresh (3hrs)
3600 ; retry (1hr)
432000 ; expire (5days)
86400 ) ; ttl (1day)
1.168.192.IN-ADDR.ARPA. IN NS sys11.edu.
; In this section put ONLY the host portion of IP address for each
; host in the one.edu domain. ex. "1 IN PTR sys11.one.edu."
1 IN PTR sys11.one.edu.
2 IN PTR sys12.one.edu.
3 IN PTR sys13.one.edu.
17 IN PTR sys17.one.edu.
254 IN PTR gw.one.edu.

关于“DNS服务器如何配置”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。