安装软件:
yum -y install bind* caching-nameserver
Cd /var/named/chroot/etc
Cp -p named.caching-nameserver.conf named.conf
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";
};
~
Vim named.rfc.1912.zones
###下面为加的部分。多个域名的指向就是在这个文件里多添加一个zone文件。
1、单个域名的指向。
zone "test.com" IN {
type master;
file "test.com.zone";
allow-update { none; };
};
zone "0.63.10.in-addr.arpa" IN {
type master;
file "10.63.0.zone";
allow-update { none; };
};
2、多个域名的指向
zone "sina.com" IN {
type master;
file "sina.com.zone";
allow-update { none; };
};
zone "test.com" IN {
type master;
file "test.com.zone";
allow-update { none; };
};
zone "0.63.10.in-addr.arpa" IN {
type master;
file "10.63.0.zone";
allow-update { none; };
};
创建数据文件。
cd /var/named/chroot/var/named
cp -f localdomain.zone test.com.zone
源文件为:
vim test.com.zone
$TTL 86400
@ IN SOA ns root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS ns
ns IN A 10.63.0.177
cp -f named.local 10.63.0.zone
源文件为:
vim 10.63.0.zone
$TTL 86400
@ IN SOA ns.test.com. root.test.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
177 IN PTR www.test.com.
177 IN PTR www.sina.com.
说明:177为IP的最后一个数字,比如,IP为10.63.0.177,这里就填写177.那这个域名就指向了10.63.0.177
如果是多个的话,则得多创建一个sina.com.zone文件
Vim sina.com.zone
$TTL 86400
@ IN SOA ns root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS ns
www IN A 10.63.0.177
给配置文件赋予相应的权限,然后重启服务。
chown -R named:named /var/named/chroot/ ##这个比较重要,要确定是否有这个权限
/etc/init.d/named restart