共计 4154 个字符,预计需要花费 11 分钟才能阅读完成。
使用 bind 配置 DNS 实验
一、实验环境:
Red Hat Enterprise Linux Server release 5.6
主机名
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
…..
配置说明: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
更多 Hadoop 相关信息见Hadoop 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=13