全部博文(163)
分类: LINUX
2009-06-15 15:36:44
Cenos5.2 +DNS
这里只将具体实现过程,写一下,原理性的东西,自己其google上搜吧~~
前提:
hostname: grid1.hrwang.com
ip:
192.168.254.142
1. 安装如下的包:
[root@grid1 named]# rpm -qa |grep
bind
bind-
bind-libs-
ypbind-1.19-8.el5
bind-sdb-
bind-utils-
bind-devel-
bind-chroot-
bind-libbind-devel-
2. 删除了/etc/下的
named.caching-nameserver.conf
named.rfc1912.zones
3. 更改/var/named/chroot/etc下的named.caching-nameserver.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";
query-source port 53;
query-source-v6 port 53;
allow-query { 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";
};
4. 更改/var/named/chroot/etc下的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 "
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 "hrwang.com" IN {
type master;
file "hrwang.com.db";
allow-update { none; };
};
zone
"254.168.192.in-addr.arpa" IN {
type master;
file "254.168.192.db";
allow-update { none; };
};
5. 在/var/named/chroot/var/named下创建 hrwang.com.db文件,用于正向解析。内容如下:
$TTL 86400
@ IN SOA grid1.hrwang.com root (
20090506 ;serial
28800 ;refresh
7200 ;retry
604800 ;expiry
86400 ) ;minimum
IN
NS grid1.hrwang.com
grid
grid
grid
6. 在/var/named/chroot/var/named下创建254.168.192.db,内容如下:
$TTL 86400
@ IN SOA grid1.hrwang.com. root.grid1.hrwang.com. (
20090506 ;serial
28800 ;refresh
7200 ;retry
604800 ;expiry
86400 ) ;minimum
IN
NS hrwang.com.
7. 权限设置
-rw-r--r-- 1 root
named 400 May 7 01:41 254.168.192.db
-rw-r--r-- 1 root
named 272 May 7 01:42 hrwang.com.db
8.配置
在/etc/resolve.conf文件中添加如下一行
nameserver 192.168.254.142
9. 启动
/etc/init.d/named
start
10. 检测
[root@grid1 named]# nslookup
192.168.254.142
Server: 192.168.254.142
Address: 192.168.254.142#53
142.254.168.192.in-addr.arpa name = grid1.hrwang.com.
[root@grid1 named]# nslookup
192.168.254.143
Server: 192.168.254.142
Address: 192.168.254.142#53
143.254.168.192.in-addr.arpa name = grid2.hrwang.com.