搭建环境:主机RHEL+虚拟机winXP+虚拟机winServer2003,其中
RHEL的IP为10.6.179.58 ,主机名为redhat,主机全名为redhat.gztcm.edu.cn;
winXP的IP为10.6.179.61,主机名为winxp,主机全名winxp.gztcm.edu.cn;
winServer2003的IP为10.6.179.59,主机名为winser,主机全名为winser.gztcm.edu.cn;
RHEL作为DNS服务器。
一、检查并安装软件
1、首先检查RHEL是否已经安装了bind软件:
[alex@redhat ~]$ rpm -qa | grep bind
bind-libs-9.3.6-16.P1.el5
bind-devel-9.3.6-16.P1.el5
bind-utils-9.3.6-16.P1.el5
bind-chroot-9.3.6-16.P1.el5
ypbind-1.19-12.el5
bind-9.3.6-16.P1.el5
bind-sdb-9.3.6-16.P1.el5
system-config-bind-4.0.3-4.el5
bind-libbind-devel-9.3.6-16.P1.el5
如未安装可在光盘里找到这些软件,然后进行安装即可。
2、确认是否也已经安装了caching-nameserver:
[alex@redhat ~]$ rpm -qa | grep caching-nameserver
caching-nameserver-9.3.6-16.P1.el5
如未安装也可在安装光盘找到并安装。
二、复制和修改主配置文件
1、进入主配置文件目录,可以看到有以下几个主要的配置文件:
[root@redhat ~]# cd /var/named/chroot/etc/
[root@redhat etc]# ls
localtime named.rfc1912.zones
named.caching-nameserver.conf named.rfc1912.zones.rpmsave
rndc.key
2、复制配置文件。因为这些文件比较重要,谨慎起见,我们对其复制并编辑副本,复制时要带上参数“-p”,以保持复制过来的配置文件的属性不会改变:
[root@redhat etc]# cp -p named.caching-nameserver.conf named.conf
3、编辑配置文件。
(1)编辑name.conf(加粗标红部分为改动的地方):
[root@redhat etc]# vi named.conf
//
// named.caching-nameserver.conf
//
// Provided by Red Hat caching-nameserver package to configure the
// ISC BIND named(8) DNS server as a caching only nameserver
// (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
// DO NOT EDIT THIS FILE - use system-config-bind or an editor
// to create named.conf - edits to this file will be lost on
// caching-nameserver package upgrade.
//
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";
// 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; };
match-destinations { any; };
recursion yes;
include "/etc/named.rfc1912.zones";
};
(2)编辑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 "gztcm.edu.cn" IN {
type master;
file "gztcm.edu.cn.zone";
allow-update { none; };
};
zone "179.6.10.in-addr.arpa" IN {
type master;
file "10.6.179.zone";
allow-update { none; };
};
三、复制并修改区域文件
1、进入区域文件目录并复制区域文件。在上边我引用了两个新文件“gztcm.edu.cn.zone”和“10.6.179.zone”,其中“gztcm.edu.cn.zone”是正向解析文件,“10.6.179.zone”为反向解析文件,其实就是在这里复制并修改的:
[root@redhat var]# cd /var/named/chroot/var/named/
[root@redhat var]# cp -p localdomain.zone gztcm.edu.cn.zone
[root@redhat var]# cp -p named.local 10.6.179.zone
2、编辑区域文件(加粗标红部分为我自己加入的):
[root@redhat named]# vi gztcm.edu.cn.zone
$TTL 86400
@ IN SOA localhost root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS localhost
redhat IN A 10.6.179.58
winser IN A 10.6.179.59
winxp IN A 10.6.179.61
[root@redhat named]# vi 10.6.179.zone
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS gztcm.edu.cn.
58 IN PTR redhat.gztcm.edu.cn.
59 IN PTR winser.gztcm.edu.cn.
61 IN PTR winxp.gztcm.edu.cn.
这里需要注意的是“10.6.179.zone”文件里的域名后是有一小点“.”的,否则DNS会理解为这是一个相对域名,在解析时会帮你加上默认的域,这是就发生错误了。另外在编辑时要用tab对齐。
3、编辑DNS服务器的本地解析文件,在文件中加入本机的DNS地址:
[root@redhat var]# vi /etc/resolv.conf
# Generated by NetworkManager
nameserver 210.38.111.150
nameserver 202.38.193.33
nameserver 10.6.179.58
4、让DNS服务器开机运行:
[root@redhat named]# chkconfig --level 2345 named on
5、测试DNS服务器。这时主要已经完成,用nslookup命令测试是否成功:
[root@redhat named]# nslookup
> redhat.gztcm.edu.cn
Server: 10.6.179.58
Address: 10.6.179.58#53
Name: redhat.gztcm.edu.cn
Address: 10.6.179.58
> winxp.gztcm.edu.cn
Server: 10.6.179.58
Address: 10.6.179.58#53
Name: winxp.gztcm.edu.cn
Address: 10.6.179.61
> winser.gztcm.edu.cn
Server: 10.6.179.58
Address: 10.6.179.58#53
Name: winser.gztcm.edu.cn
Address: 10.6.179.59
>
由nslookup测试可以看出DNS正常工作,即搭建DNS服务器成功!
阅读(2229) | 评论(0) | 转发(0) |