rhel5 配置局域网dns 笔记
1. 安装bind
#yum install bind*
#yum install caching-nameserver
2. 修改配置文件
#cd /var/named/chroot/etc
#vi 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 { 127.0.0.1; };
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 { localhost; };
// match-destinations { localhost; };
// recursion yes;
// include "/etc/named.rfc1912.zones";
//};
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};

zone "." IN {
type hint;
file "named.ca";
};

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 "pig.com" IN {
type master;
file "db.pig.com";
allow-update { none;};
};

zone "0.168.192.in-addr.arpa" IN{
type master;
file "db.192.168.0";
allow-update { none;};
};

include "/etc/rndc.key";
检查配置文件
#named-checkconf named.caching-nameserver.conf
3. 创建正向和反向解析的数据库文件
#cd /var/named/chroot/var/named/
# uname -n
rhel-aaron
#vi db.pig.com
内容如下,蓝色部分顶格填写, rhel-aaron 文件机器名:
$TTL 86400
@ IN SOA rhel-aaron.pig.com. root.pig.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum

IN NS rhel-aaron.pig.com.
rhel-aaron IN A 192.168.0.111
dns IN A 192.168.0.111
www IN A 192.168.0.111
ftp IN A 192.168.0.111
mail IN A 192.168.0.111
web IN CNAME 192.168.0.111
#vi db.192.168.0
内容如下,蓝色部分顶格填写, rhel-aaron 文件机器名,注意点号必须有:
$TTL 86400
@ IN SOA rhel-aaron.pig.com. root.pig.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS rhel-aaron.pig.com.
111 IN PTR rhel-aaron.pig.com.
111 IN PTR dns.pig.com.
111 IN PTR www.pig.com.
111 IN PTR ftp.pig.com.
111 IN PTR mail.pig.com.
检查解析数据库文件是否正确:
# named-checkzone pig.com db.pig.com
zone pig.com/IN: loaded serial 42
OK
# named-checkzone pig.com db.192.168.0
zone pig.com/IN: loaded serial 1997022700
OK
4. 修改/etc/resolv.conf
#vi /etc/resolv.conf
nameserver 127.0.0.1
search localdomain
5. 重启所有相关服务
# service network restart
# service named start
6. 测试
# nslookup www.pig.com
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: www.pig.com
Address: 192.168.0.111
# nslookup 192.168.0.111
Server: 127.0.0.1
Address: 127.0.0.1#53
11.0.168.192.in-addr.arpa name = www.pig.com.
测试成功!!
#yum install bind*
#yum install caching-nameserver
2. 修改配置文件
#cd /var/named/chroot/etc
#vi named.caching-nameserver.conf
修改内容如下(红色标记):







































































#named-checkconf named.caching-nameserver.conf
3. 创建正向和反向解析的数据库文件
#cd /var/named/chroot/var/named/
# uname -n
rhel-aaron
#vi db.pig.com
内容如下,蓝色部分顶格填写, rhel-aaron 文件机器名:
















内容如下,蓝色部分顶格填写, rhel-aaron 文件机器名,注意点号必须有:














# named-checkzone pig.com db.pig.com
zone pig.com/IN: loaded serial 42
OK
# named-checkzone pig.com db.192.168.0
zone pig.com/IN: loaded serial 1997022700
OK
4. 修改/etc/resolv.conf
#vi /etc/resolv.conf


# service network restart
# service named start
6. 测试
# nslookup www.pig.com
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: www.pig.com
Address: 192.168.0.111
# nslookup 192.168.0.111
Server: 127.0.0.1
Address: 127.0.0.1#53
11.0.168.192.in-addr.arpa name = www.pig.com.
测试成功!!