Linux 下 DNS的配置

1、进入光盘软件包所在的目录 

[root@localhost ~]# cd /media/RHEL_5.4\ x86_64\ DVD/Server/   
[root@localhost Server]# find -name "bind*"
    ./bind-9.3.6-4.P1.el5.x86_64.rpm
    ./bind-chroot-9.3.6-4.P1.el5.x86_64.rpm
    ./bind-devel-9.3.6-4.P1.el5.i386.rpm
    ./bind-devel-9.3.6-4.P1.el5.x86_64.rpm
    ./bind-libbind-devel-9.3.6-4.P1.el5.i386.rpm
    ./bind-libbind-devel-9.3.6-4.P1.el5.x86_64.rpm
    ./bind-libs-9.3.6-4.P1.el5.i386.rpm
    ./bind-libs-9.3.6-4.P1.el5.x86_64.rpm
    ./bind-sdb-9.3.6-4.P1.el5.x86_64.rpm
    ./bind-utils-9.3.6-4.P1.el5.x86_64.rpm
[root@localhost Server]# find -name "cach*"
    ./caching-nameserver-9.3.6-4.P1.el5.x86_64.rpm 
[root@localhost Server]# rpm -ivh "bind*"
[root@localhost Server]# rpm -ivh "cach*"

 

2、修改配置文件 

[root@localhost ~]# vi /etc/named.caching-nameserver.conf 
    options {
            listen-on port 53 { any; };        //将127.0.0.1改为any,也可以设定具体的地址
            listen-on-v6 port 53 { any; };    //将127.0.0.1改为any
            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";

            // Those options should be used carefully because they disable port
            // randomization
            // query-source    port 53;
            // query-source-v6 port 53;

            allow-query     { any; };
            allow-query-cache { any; };
    };
    logging {
            channel default_debug {
                    file "data/named.run";
                    severity dynamic;
            };
    };
    view localhost_resolver {
            match-clients      { any; };    //将127.0.0.1改为any
            match-destinations { any; };    //将127.0.0.1改为any
            recursion yes;    
            include "/etc/named.rfc1912.zones";
    };

3、编辑dns服务器的区域主配置文件:

[root@localhost ~]# vi /etc/named.rfc1912.zones 
    //可以加到最后
    zone "founder.com" IN{
          type master;
          file "named.founder"; // named.founder本区域的配置文件
    };

    zone "165.29.172.in-addr.arpa" IN{
            type master;
            file "named.172.29.165";//反向解析区域配置文件
    };
    

4、建立正反解的对应文档 

[root@localhost ~]# cd /var/named/chroot/var/named/ 
[root@localhost named]# cp named.local named.founder    //(利用模板复制再修改)
[root@localhost named]# cp named.local named.172.29.165
[root@localhost named]# chown named:named named.founder     //(修改uid和gid)
[root@localhost named]# chown named:named named.172.29.165     //(修改uid和gid)
[root@localhost named]# vi named.founder 
    $TTL    86400
    @       IN      SOA     localhost. root.localhost.  (
                                          1997022700 ; Serial
                                          28800      ; Refresh
                                          14400      ; Retry
                                          3600000    ; Expire
                                          86400 )    ; Minimum
            IN      NS      localhost.
    1       IN      PTR     localhost.
    racnode1     IN      A     172.29.165.221
    racnode2     IN      A     172.29.165.222
    racnode1-priv     IN      A     192.168.142.128
    racnode2-priv     IN      A     192.168.142.129
    racnode1-vip     IN      A     172.29.165.211
    racnode2-vip     IN      A     172.29.165.212
    racnode-cluster-scan     IN      A     172.29.165.1
    racnode-cluster-scan     IN      A     172.29.165.2
racnode-cluster-scan IN A 172.29.165.3
[root@localhost named]# vi named.172.29.165 $TTL 86400 @ IN SOA localhost. root.localhost. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS localhost. 1 IN PTR localhost. 221 IN PTR racnode1.founder.com 222 IN PTR racnode2.founder.com 128 IN PTR racnode1-priv.founder.com 129 IN PTR racnode1-priv.founder.com 211 IN PTR racnode1-vip.founder.com 212 IN PTR racnode2-vip.founder.com 1 IN PTR racnode-cluster-scan.founder.com 2 IN PTR racnode-cluster-scan.founder.com
3 IN PTR racnode-cluster-scan.founder.com ~

5、修改DSN地址

[root@localhost named]# vi /etc/resolv.conf    
    ; generated by /sbin/dhclient-script
    #search localdomain
    #nameserver 192.168.107.1

    search founder.com
    nameserver 172.29.165.230
    ~     

 

6、测试   不是DNS服务器上测试时,注意修改测试机上的DNS

[root@localhost named]# service named restart
    停止 named:                                               [确定]
    启动 named:                                               [确定]
[root@localhost named]# nslookup
    > 172.29.165.221
    Server:         172.29.165.230
    Address:        172.29.165.230#53

    221.165.29.172.in-addr.arpa     name = racnode1.founder.com.165.29.172.in-addr.arpa.
    > racnode1.founder.com
    Server:         172.29.165.230
    Address:        172.29.165.230#53

    Name:   racnode1.founder.com
    Address: 172.29.165.221
    > exit

[root@localhost named]# 
posted @ 2012-06-10 00:45  VipSoft  阅读(571)  评论(0编辑  收藏  举报