查看文章
 
Bind9配置
2008年02月16日 星期六 5:19

master配置

1、编辑/etc/named.conf文件成如下形式:

options{

         directory "/var/named";

         allow-query{192.168.1.0/24};    指定允许进行域名解析的主机

};

zone "." IN{                  定义根域

         type hint;

         file "named.ca";

};

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;};

};

2、启动Bind9

#service named start

客户端配置

编辑/etc/resolv.conf,将DNS服务器加入

nameserver 192.168.1.1

nameserver 192.168.1.2

用nslookup测试

#nslookup

>www.sina.com.cn


如能正确解析,说明配置好了(在此之前必须确保服务器已经连入Internet)

1、编辑/etc/named.conf,添加如下内容:

zone "ncie.org"{

          type master;

          file "named.ncie.org";

};

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

          type master;

          file "named.192.168.1";

};

2、编辑ncie.org区域的区数据库配置文件/var/named/named.ncie.org,内容如下:

$TTL 300

@              SOA      ns1.ncie.org.       root.ns1.ncie.org.(

                        2003053013;serial

                        3600;refresh

                        900;retry

                        1209600;expire

                        3600;minimum

                        )

@        IN       NS           ns1

ns1      IN       A            192.168.1.1

www      IN       CNAME        ns1

host2    IN       A            192.168.1.2

host3    IN       A            192.168.1.3

host4    IN       A            192.168.1.4

3、编辑1.168.192.in-addr.arpa区域的配置文件/var/named/named.192.168.1,内容如下:

$TTL 300

@              SOA      ns1.ncie.org.       root.ns1.ncie.org.(

                        2003053013;serial

                        3600;refresh

                        900;retry

                        1209600;expire

                        3600;minimum

                        )

@        IN       NS           ns1.ncie.org.

1        IN       PTR          ns1.ncie.org.

2        IN       PTR          host2.ncie.org.

3        IN       PTR          host3.ncie.org.

4        IN       PTR          host4.ncie.org.

4、重启Bind9

#service named restart

客户端配置

编辑/etc/resolv.conf,加入默认搜索域和域名服务器,内容如下

domain ncie.org

search ncie.org

nameserver 192.168.1.1

用nslookup测试

#nslookup

>set all      查询所有类型

>host4

>www.sina.com.cn

>

>set type=ANY          查询更详细的信息

>www.sina.com.cn

>

>server ns1.sina.com.cn.     登录到域外的主机执行命令

>www.sina.com.cn

>

>server ns1.ncie.org.

>set type=PTR

>192.168.1.4

>

>set type=CNAME

>www.ncie.org

>exit

配置辅域名服务器

1、在局域网内的另一台服务器上安装Bind9

2、编辑此服务器上的/etc/named.conf,内容如下:

zone "ncie.org"{

        type slave;

        file "named.ncie.org";

        masters{192.168.1.1;};

};

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

        type slave:

        file "named.192.168.1";

        masters{192.168.1.1;};

};

3、编辑主域名服务器上的/etc/named.conf文件,在options区段加入如下行,设置允许辅域名服务器从主域名服务器同步区域数据库

allow-transfer{192.168.1.2;};

4、启动辅域名服务器: service named start

5、登录客户机测试

#nslookup

>server 192.168.1.2

>host4.ncie.org


配置区域委派

实验步骤:

1、编辑主域名服务器中的ncie.org区域配置文件named.ncie.org,在其中添加如下内容,为区域lab.ncie.org设置主域名服务器和辅域名服务器。

ns2               IN     A        192.168.1.101

ns3               IN     A        192.168.1.102

lab.ncie.org.     IN     NS       ns2.ncie.org.

lab.ncie.org.     IN     NS       ns3.ncie.org.

2、再分别到两台接受委派的机器上建立A记录,以下以192.168.1.101机器为例

ns1     IN    A     192.168.1.102

@       IN    NS    ns1.lab.ncie.org

3、service named restart

4、客户机测试:(将客户端的DNS指向ns1.ncie.org)

#nslookup

>server ns1.ncie.org.

>set type=NS

>lab.ncie.org.


提示:bind很容易出现的就是cann't find server name ,这是由于你没有给服务器设置正确的反向解析造成的,你要给监听53号端口的ip地址设置一个正确的反向解析。

附注:适合DNS服务器的iptables配置

#!/bin/bash
PATH=/sbin:/usr/sbin:/usr/bin;export PATH
iptables -F
iptables -X
iptables -Z

iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT

iptables -A INPUT -i eth0 -p udp --dport 53 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -i eth0 -p udp --dport 22 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT


类别:Server||添加到搜藏 |分享到i贴吧|浏览(754)|评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
     

   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu