Chinaunix首页 | 论坛 | 博客
  • 博客访问: 556378
  • 博文数量: 114
  • 博客积分: 5611
  • 博客等级: 大校
  • 技术积分: 1027
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-19 08:55
文章分类

全部博文(114)

文章存档

2011年(29)

2010年(20)

2009年(1)

2008年(11)

2007年(53)

分类: LINUX

2011-03-24 13:39:08

设置DNS功能

 

.bind安装

总共有以下这些和bind相关的rpm包需要安装

bind-sdb-9.3.6-4.P1.el5_4.2

ypbind-1.19-12.el5

bind-libbind-devel-9.3.6-4.P1.el5_4.2

bind-utils-9.3.6-4.P1.el5_4.2

bind-libs-9.3.6-4.P1.el5_4.2

bind-devel-9.3.6-4.P1.el5_4.2

bind-9.3.6-4.P1.el5_4.2

bind-chroot-9.3.6-4.P1.el5_4.2

另外还需要一个:

caching-nameserver-9.3.6-4.P1.el5_4.2

可以通过rpm -qa |grep bind

        rpm -qa |grep caching-nameserver 来查找系统中这些包是否存在

通过rpm -rvh 将缺失的包安装到系统中

或者通过yum install bind*来升级和安装(如果网络配置好了就用这种办法

 

.BIND配置

由于chroot技术的使用,BIND配置文件named.conf/var/named/chroot/etc/下,而区域配置文件在/var/named/chroot/var/named/

另外其文件属性需要修改为root.named,否则会造成DNS解析错误。

 chown root.named 文件名

如果是yum 安装的话不需要修改root named的文件所有者

配置域名:mail.sinoxxxxxx.com,机器IP172.21.41.12

# cd /var/named/chroot/etc/

# ls -al

total 24

-rw-r--r-- 1 root root   405 Feb 7 19:36 localtime

-rw-r----- 1 root named 1230 Jan 21 00:33 named.caching-nameserver.conf

-rw-r----- 1 root named 955 Jan 21 00:33 named.rfc1912.zones

-rw-r----- 1 root named 113 Mar 18 16:33 rndc.key

以上是/var/named/chroot/etc/下的主要配置文件,不要去改动,

进行复制的时候要加上参数-P,这样文件的属性不会改变。

# cp -p named.caching-nameserver.conf named.conf

这样我们就可以用vi打开named.conf进行修改了

 

options {

    listen-on port 53 { any; };

    listen-on-v6 port 53 { ::1; };

    directory     "/var/named";

    dump-file     "/var/named/data/cache_dump.db";

        statistics-file "/var/named/data/named_stats.txt";

        memstatistics-file "/var/named/data/named_mem_stats.txt";

    query-source    port 53;   

    query-source-v6 port 53;

    allow-query     { any; };

   allow-query-cache { any; };

forwarders {218.2.135.1;221.228.255.1;202.102.3.144;};

};

logging {

        channel default_debug {

                file "data/named.run";

                severity dynamic;

        };

};

view localhost_resolver {

    match-clients         { any; };

    match-destinations { any; };

    recursion yes;

    include "/etc/named.rfc1912.zones";

};

[root@localhost etc]# cp named.rfc1912.zones -p named.rfc1912.zones.bak

[root@localhost etc]# vi named.rfc1912.zones

// named.rfc1912.zones:

//

// Provided by Red Hat caching-nameserver package

//

// ISC BIND named zone configuration for zones recommended by

// RFC 1912 section 4.1 : localhost TLDs and address zones

//

// See /usr/share/doc/bind*/sample/ for example named configuration files.

//

zone "." IN {

        type hint;

        file "named.ca";

};

zone "localdomain" IN {

        type master;

        file "localdomain.zone";

        allow-update { none; };

};

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

};

zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN

{

        type master;

        file "named.ip6.local";

        allow-update { none; };

};

zone "255.in-addr.arpa" IN {

        type master;

        file "named.broadcast";

        allow-update { none; };

};

zone "0.in-addr.arpa" IN {

        type master;

        file "named.zero";

        allow-update { none; };

};

zone "sinoxxxxxx.com" IN {

     type master;

     file "sinoxxxxxx.com.zone";

     allow-update { none; };

};

zone "41.21.172.in-addr.arpa" IN {

     type master;

     file "172.21.41.zone";

     allow-update { none; };

};

 

# cd /var/named/chroot/var/named/

# ls -al

drwxrwx--- 2 named named 4096 Aug 26  2004 data

-rw-r----- 1 root  named  198 Dec 14 02:10 localdomain.zone

-rw-r----- 1 root  named  195 Dec 14 02:10 localhost.zone

-rw-r----- 1 root  named  427 Dec 14 02:10 named.broadcast

-rw-r----- 1 root  named 1892 Dec 14 02:10 named.ca

-rw-r----- 1 root  named  424 Dec 14 02:10 named.ip6.local

-rw-r----- 1 root  named  426 Dec 14 02:10 named.local

-rw-r----- 1 root  named  427 Dec 14 02:10 named.zero

drwxrwx--- 2 named named 4096 Jul 27  2004 slaves

 

# cp -p localdomain.zone sinoxxxxxx.com.zone

# cp -p named.local 172.21.41.zone

# vi 172.21.41.zone

$TTL    86400

@      IN      SOA     localhost. root.localhost. (

                                      1997022700 ; Serial

                                      28800      ; Refresh

                                      14400      ; Retry

                                      3600000    ; Expire

                                      86400 )    ; Minimum

        IN      NS      localhost.

12       IN      PTR     mail.sinoxxxxxx.com.

这里的数字12是服务器地址的最后一位

 

# vi sinoxxxxxx.com.zone

$TTL    86400

@               IN SOA localhost root (

                                        42              ; serial (d. adams)

                                        3H              ; refresh

                                        15M             ; retry

                                        1W              ; expiry

                                        1D )            ; minimum

                IN NS           localhost

mail      IN A            172.21.41.12

 

vi /etc/resolv.conf

; generated by /sbin/dhclient-script

search localdomain

nameserver 172.21.41.12

 

# /etc/init.d/named restart

Stopping named: [ OK ]

Starting named: [ OK ]

 

# chkconfig --level 345 named on

# nslookup

mail. sinoxxxxxx.com

Server:         172.21.41.12

Address:        172.21.41.12#53

Name:   mail.sinoxxxxxx.com

Address: 172.21.41.12

 

 

 

阅读(1123) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~