DNS的基本配置
所需安装包及环境
caching-nameserver-9.3.4-10.P1.el5 (用于创建named.conf的)
bind-9.3.4-10.P1.el5
bind-utils-9.3.4-10.P1.el5
ip地址:192.168.0.60
主机名:nis
DNS域名:nis.yuetao.com
查看上述包是否安装
[root@nis ~]# rpm -qa | grep bind
ypbind-1.19-11.el5
bind-libs-9.3.4-10.P1.el5
bind-9.3.4-10.P1.el5
bind-utils-9.3.4-10.P1.el5(没用这三个文件请自己安装上)
所需条件
①主机名的配置
vim /etc/sysconfig/network
HOSTNAME=nis (你本机的主机名,后期会用到)
DNS域名的配置
nameserver 192.168.0.60 (你本机的dnsip地址最多可以配置三个地址)
配置的具体步骤
①创建named.conf 的配置文件
cat /etc/named.caching-nameserver.conf >> /etc/named.conf
cat /etc/named.rfc1912.zones >> /etc/named.conf
②编辑named.conf文件 (路径:/etc/named.conf
在配置文件末尾添加如下类容
正向解析区域:
zone "yuetao.com" IN {              //正向解析
        type master;               //master 说明是主域服务器
        file "yuetao.com.zone";     //正向区域文件的名与 /var/named/yuetao.com.zone 文件的名保持一致
        allow-update { none; };      //是否允许更新文件
};
反向解析区域:
zone "0.168.192.in-addr.arpa" IN {     //反向解析
        type master;
        file "yuetao.com.arpa";      //反向区域文件名与 /var/named/yuetao.com.arpa 文件名保持一致。
        allow-update { none; };
};
 
配置文件如下:
    listen-on port 53 { 192.168.0.60; };
    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";
    allow-query     { localhost; };
};
 
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
 
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; };
};
 
        type master;
        file "yuetao.com.zone";
        allow-update { none; };
};
 
        type master;
        file "yuetao.com.arpa";
        allow-update { none; };
};
/var/named下创建yuetao.com.zone yuetao.com.rape (这两个文件时没有的要自己创建这和前面的/etc/named.conf 的文件有关联的,与前面的名称一定要一致。)
 
cp -p localhost.zone  yuetao.com.zone
cp -p localhost.zone  yuetao.com.arpa
 
编辑以上两个文件
yuetao.com.zone 的配置文件
$TTL    86400
@               IN SOA  nis.yuetao.com.      root.nis.yuetao.com. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
 
@               IN NS           nis.yuetao.com.
www             IN A            192.168.0.60
ftp               IN A            192.168.0.60
 
 
yuetao.com.arpa 的配置文件
$TTL    86400
@               IN SOA  nis.yuetao.com.       root.nis.yuetao.com. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
 
@              IN NS           nis.yuetao.com.
60              IN PTR          www.yuetao.com.
60              IN PTR          ftp.yuetao.com(以上两个文件要注意域名后有顿号不然你会死的很惨)
 
重启服务 service named restart
测试是否成功:
Server:         192.168.0.60
Address:        192.168.0.60#53
 
Name:   www.yuetao.com
Address: 192.168.0.60
 
[root@nis ~]# nslookup ftp.yuetao.com
Server:         192.168.0.60
Address:        192.168.0.60#53
 
Name:   ftp.yuetao.com
Address: 192.168.0.60
 
Server:         192.168.0.60
Address:        192.168.0.60#53
 
60.0.168.192.in-addr.arpa       name = ftp.yuetao.com.0.168.192.in-addr.arpa.
60.0.168.192.in-addr.arpa       name = www.yuetao.com.0.168.192.in-addr.arpa.
 
基本配置完成打完收工该干嘛干嘛去。
 
 
DNS 主从域的配置
紧接上一篇我们来看看主从域的安装与配置
 
一更改option中的一个选项
 
options {
    listen-on port 53 { 192.168.0.60; };
    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";
    allow-query     { any; };    //允许所有人来侦听这个域 主从都要改
};
 
二主域服务器的区域文件的更改。
        type master;
        file "yuetao.com.zone";
        allow-transfer { 192.168.0.61; }; //允许从域主机能够下载该区域的地址数据库
};
 
 
zone "0.168.192.in-addr.arpa" IN {
        type master;
        file "yuetao.com.arpa";
}
 
 
三从域服务器区域文件的修改。
zone "yuetao.com" IN {
        type slave;
        file "slaves/yuetao.com.zone"; //下载主域的地址库数据文件保存在slaves 目录中,从域服务器上的区域文夹可以与主域服务器上的文件名不同。
        mastes { 192.168.0.60 } //指定主域服务器的IP地址
 
zone "0.168.192.in-addr.arpa" IN {
        type slave;
        file "slaves/yuetao.com.arpa";
        mastes { 192.168.0.60 }
};
四 主从域服务器/etc/resolv.conf 配置文件的修改
nameserver 192.168.0.60
nameserver 192.168.0.61
重启两台机器
①查看从域服务器上/var/named/slaves 文件中是否存在yuetao.com.zone  yuetao.com.arpa 两个文件是否存在。
②在从域服务器中使用nslookup 查看能不能给解析过来
Server:         192.168.0.60
Address:        192.168.0.60#53
 
Name:   www.yuetao.com
Address: 192.168.0.60
 
[root@nis2 ~]# nslookup 192.168.0.60
Server:         192.168.0.60
Address:        192.168.0.60#53
 
60.0.168.192.in-addr.arpa       name = ftp.yuetao.com.0.168.192.in-addr.arpa.
60.0.168.192.in-addr.arpa       name = www.yuetao.com.0.168.192.in-addr.arpa.
 
 
③关掉主域服务器使用nslookup 看是否能解析过来
[root@nis2 ~]# nslookup www.yuetao.com
Server:         192.168.0.60
Address:        192.168.0.60#53
 
Name:   www.yuetao.com
Address: 192.168.0.60
 
[root@nis2 ~]# nslookup 192.168.0.60
Server:         192.168.0.60
Address:        192.168.0.60#53
 
60.0.168.192.in-addr.arpa       name = ftp.yuetao.com.0.168.192.in-addr.arpa.
60.0.168.192.in-addr.arpa       name = www.yuetao.com.0.168.192.in-addr.arpa.
 
成功结束