需要准备3个IP
eth0 192.168.71.128
ifconfig eth0:2 192.168.73.1
ifconfig eth0:1 192.168.72.1
1.安装软件包
yum -y install bind
2.修改配置文件
vi /etc/named.conf
acl dx { 192.168.71.0/24; };
acl wt { 192.168.72.0/24; };
acl others { 192.168.73.0/24; };
options {
listen-on port 53 { 127.0.0.1; any; };
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";
allow-query { localhost; any; };
recursion yes;
dnssec-enable no;
dnssec-validation no;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view dx_view{
match-clients { dx; };
allow-query { dx; };
include "/etc/named.dx.zones";
include "/etc/named.root.key";
};
view wt_view{
match-clients { wt; };
allow-query { wt; };
include "/etc/named.wt.zones";
include "/etc/named.root.key";
};
view others_view{
match-clients { others; };
allow-query { any; };
include "/etc/named.others.zones";
include "/etc/named.root.key";
};
cp -a /etc/named.rfc1912.zones /etc/named.dx.zones
cp -a /etc/named.rfc1912.zones /etc/named.wt.zones
cp -a /etc/named.rfc1912.zones /etc/named.others.zones
vi /etc/named.dx.zones
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost.localdomain" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "1.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.loopback";
allow-update { none; };
};
zone "1.0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.empty";
allow-update { none; };
};
zone "qq.com" IN {
type master;
file "/var/named/qq.com.zone.dx";
allow-update { none; };
};
vi /etc/named.wt.zones
zone "qq.com" IN {
type master;
file "/var/named/qq.com.zone.wt";
allow-update { none; };
};
vi /etc/named.others.zones
zone "qq.com" IN {
type master;
file "/var/named/qq.com.zone.others";
allow-update { none; };
};
3.新建区域文件
cd /var/named/
cp -a named.localhost qq.com.zone.dx
vi qq.com.zone.dx
$TTL 1D
@ IN SOA dns.qq.com. root.qq.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS dns.qq.com.
dns A 192.168.71.128
www A 192.168.71.100
cp -a qq.com.zone.dx qq.com.zone.wt
cp -a qq.com.zone.dx qq.com.zone.others
vi qq.com.zone.wt
$TTL 1D
@ IN SOA dns.qq.com. root.qq.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS dns.qq.com.
dns A 192.168.72.1
www A 192.168.72.100
vi qq.com.zone.others
$TTL 1D
@ IN SOA dns.qq.com. root.qq.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS dns.qq.com.
dns A 192.168.73.1
www A 192.168.73.100
测试
[root@server named]# nslookup
> server
Default server: 192.168.71.128
Address: 192.168.71.128#53
> www.qq.com
Server: 192.168.71.128
Address: 192.168.71.128#53
Name: www.qq.com
Address: 192.168.71.100
> server 192.168.72.1
Default server: 192.168.72.1
Address: 192.168.72.1#53
> www.qq.com
Server: 192.168.72.1
Address: 192.168.72.1#53
Name: www.qq.com
Address: 192.168.72.100
> server 192.168.73.1
Default server: 192.168.73.1
Address: 192.168.73.1#53
> www.qq.com
Server: 192.168.73.1
Address: 192.168.73.1#53
Name: www.qq.com
Address: 192.168.73.100