使用bind配置DNS实验
一、实验环境:
Red Hat Enterprise Linux Server release 5.6
主机名 www.2cto.com
IP
系统版本
Host role
hotel01
192.168.2.111
OEL5.6
server
hotel02
192.168.2.112
OEL5.6
client
hotel03
192.168.2.113
OEL5.6
client
…..
www.2cto.com
配置说明:NDS服务器放在了hotel01(master)节点上,对hotel01、hotel02、hotel03节点的主机名进行解析。
二、安装配置DNS
1. 安装bind、caching-nameserver软件包
--因使用的是未注册的OEL版本,所以yum不能在线安装bind软件
--安装下面bind包,如果缺少可以在安装盘上查找并安装
[root@hotel01 ~]# rpm -qa|grep bind
bind-utils-9.3.6-16.P1.el5
ypbind-1.19-12.el5
bind-chroot-9.3.6-16.P1.el5
bind-9.3.6-16.P1.el5
bind-libs-9.3.6-16.P1.el5
bind-libbind-devel-9.3.6-16.P1.el5
bind-devel-9.3.6-16.P1.el5
bind-libs-9.3.6-16.P1.el5
[root@hotel01 ~]# rpm -qa|grep caching-nameserver
caching-nameserver-9.3.6-16.P1.el5
2. 修改bind配置文件
BIND的配置文件name.conf还有区域文件都在/var/named/chroot/目录下
配置文件named.conf在/var/named/chroot/etc/下,区域配置文件在/var/named/chroot/var/named/下
1) 修改配置文件named.conf
[root@hotel01 ~]# cd /var/named/chroot/etc
[root@hotel01 etc]# cp -p named.caching-nameserver.conf named.conf
[root@hotel01 etc]# vi named.conf
options {
listen-on port 53 { any; }; --把127.0.0.1改成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; }; --把localhost改成any
match-destinations { any; }; --把localhost改成any
recursion yes;
include "/etc/named.rfc1912.zones";
};
2) 修改配置文件named.rfc1912.zones,在文件中添加以下内容
[root@hotel01 etc]# pwd
/var/named/chroot/etc
[root@hotel01 etc]# vi named.rfc1912.zones
zone "licz.com" IN { //这是自己设置的域名
type master;
file "licz.com.zone";
allow-update { none; };
};
zone "2.168.192.in-addr.arpa" IN { //这是反向配置文件
type master;
file "2.168.192.in-addr.zone";
allow-update { none; };
};
3) 创建leonarding.com.zone和2.168.192.in-addr.zon 区域文件
[root@hotel01 etc]# cd /var/named
[root@hotel01 named]# cp -p localdomain.zone chroot/var/named/licz.com.zone
[root@hotel01 named]# cp -p named.local chroot/var/named/2.168.192.zone
--修改leonarding.com.zone和2.168.192.in-addr.zon 区域文件
[root@hotel01 named]# cd /var/named/chroot/var/named
[root@hotel01 named]# vi licz.com.zone
$TTL 86400
@ IN SOA localhost root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS localhost
//添加下面的正向文件内容
hotel01 IN A 192.168.2.111
hotel02 IN A 192.168.2.112
hotel03 IN A 192.168.2.113
[root@hotel01 named]# vi 2.168.192.in-addr.zone
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
//添加下面的反向向文件内容
111 IN PTR hotel01.licz.com
112 IN PTR hotel02.licz.com
113 IN PTR hotel03.licz.com
4) 修改各节点/etc/resolv.conf文件
[root@hotel01 named]# vi /etc/resolv.conf
nameserver 192.168.2.111
[root@hotel02 named]# vi /etc/resolv.conf
nameserver 192.168.2.111
[root@hotel03 named]# vi /etc/resolv.conf
nameserver 192.168.2.111
3. 验证测试
[root@hotel01 etc]# nslookup
> hotel01.licz.com
Server: 192.168.2.111
Address: 192.168.2.111#53
Name: hotel01.licz.com
Address: 192.168.2.111
> hotel02.licz.com
Server: 192.168.2.111
Address: 192.168.2.111#53
Name: hotel02.licz.com
Address: 192.168.2.112
> hotel03.licz.com
Server: 192.168.2.111
Address: 192.168.2.111#53
Name: hotel03.licz.com
Address: 192.168.2.113
[root@hotel01 named]# ping hotel03.licz.com
PING hotel03.licz.com (192.168.2.113) 56(84) bytes of data.
64 bytes from hotel03 (192.168.2.113): icmp_seq=1 ttl=64 time=10.8 ms
64 bytes from hotel03 (192.168.2.113): icmp_seq=2 ttl=64 time=0.360 ms
64 bytes from hotel03 (192.168.2.113): icmp_seq=3 ttl=64 time=0.332 ms
64 bytes from hotel03 (192.168.2.113): icmp_seq=4 ttl=64 time=0.299 ms
64 bytes from hotel03 (192.168.2.113): icmp_seq=5 ttl=64 time=0.306 ms
文章出处:
http://www.2cto.com/os/201303/193654.html