Linux多DNS服务
一、 实验目标
一台Linux服务器提供多个DNS服务。
二、 实验环境
Linux服务器版本为Red Hat Enterprise Linux Server release 5.2 (Tikanga),内核版本号2.6.18-92.el5;两台客户端主机。
三、 实施步骤
1、 安装bind软件包
放入安装光盘,并切换到软件包所在目录,执行下列命令安装相应软件包:
rpm -ivh bind-9.3.4-6.P1.el5.i386.rpm
rpm -ivh bind-chroot-9.3.4-6.P1.el5.i386.rpm
rpm -ivh bind-devel-9.3.4-6.P1.el5.i386.rpm
rpm -ivh bind-libbind-devel-9.3.4-6.P1.el5.i386.rpm
rpm -ivh bind-libs-9.3.4-6.P1.el5.i386.rpm
rpm -ivh bind-sdb-9.3.4-6.P1.el5.i386.rpm
rpm -ihv bind-utils-9.3.4-6.P1.el5.i386.rpm
rpm -ivh caching-nameserver-9.3.4-6.P1.el5.i386.rpm
2、 创建、修改配置文件
1) 创建第二个DNS服务的相关配置文件
[root@server ~]# cp -a /var/named /var/dns 注:-a参数保留目录及其以下文件属性
对链接文件重新链接到正确的目标文件。把/var/dns/chroot/var/named目录更名为/var/dns/chroot/var/dns
2) 第一个DNS服务修改后的内容如下:
[root@server ~]# cat /var/named/chroot/etc/named.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 { 192.168.13.11; };
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;
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
recursion yes;
include "/etc/named.rfc1912.zones";
};
[root@server ~]# cat /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 "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
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 "china.test" IN {
type master;
file "china.test.zone";
allow-update { none; };
};
zone "13.168.192.in-addr.arpa" IN {
type master;
file "china.test.arpa";
allow-update { none; };
};
3) 第二个DNS服务的主配置文件内容如下:
[root@server ~]# cat /var/dns/chroot/etc/dns.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 54 { 192.168.13.11; };
listen-on-v6 port 54 { ::1; };
directory "/var/dns";
dump-file "/var/dns/data/cache_dump.db";
statistics-file "/var/dns/data/named_stats.txt";
memstatistics-file "/var/dns/data/named_mem_stats.txt";
query-source port 54;
query-source-v6 port 54;
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
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 "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
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 "china.test" IN {
type master;
file "china.test.zone";
allow-update { none; };
};
zone "13.168.192.in-addr.arpa" IN {
type master;
file "china.test.arpa";
allow-update { none; };
};
4) 第一个DNS服务的域文件内容如下:
[root@server ~]# cat /var/named/chroot/var/named/china.test.zone
$TTL 86400
@ IN SOA server.china.test. admin.china.test. (
2009062100
28800
14400
360000
86400
)
NS server.china.test.
server IN A 192.168.13.11
client IN A 192.168.13.24
HT08126 IN A 192.168.13.23
[root@server ~]# cat /var/named/chroot/var/named/china.test.arpa
$TTL 86400
@ IN SOA server.china.test. admin.china.test. (
2009062100
28800
14400
360000
86400
)
@ NS server.china.test.
11 IN PTR server.china.test.
23 IN PTR HT08126.china.test.
24 IN PTR client.china.test.
5) 第二个DNS服务的域名文件内容如下:
[root@server ~]# cat /var/dns/chroot/var/dns/china.test.zone
$TTL 86400
@ IN SOA server.china.test. admin.china.test. (
2009062100
28800
14400
360000
86400
)
NS server.china.test.
server IN A 192.168.13.11
client IN A 192.168.13.14
HT08126 IN A 192.168.13.13
[root@server ~]# cat /var/dns/chroot/var/dns/china.test.arpa
$TTL 86400
@ IN SOA server.china.test. admin.china.test. (
2009062100
28800
14400
360000
86400
)
@ NS server.china.test.
11 IN PTR server.china.test.
13 IN PTR HT08126.china.test.
14 IN PTR client.china.test.