DNS主从+TSIG认证+View视图配置
##############################################################################
系统环境:
RHEL 5.5 [2.6.18-238.el5]
软件环境:
bind-9.3.6-4.P1.el5_4.2
bind-chroot-9.3.6-4.P1.el5_4.2
网络配置:
主DNS服务器——
主机名:ns1.mydomain.com IP地址:192.168.4.111
从DNS服务器——
主机名:ns2.mydomain.com IP地址:192.168.4.112
##############################################################################
一、DNS主从+TSIG认证
1.生成对称密钥字串
[root@ns1 ~]# dnssec-keygen -a hmac-md5 -b 128 -n HOST ns1-ns2
Kns1-ns2.+157+02839
[root@ns1 ~]# cat Kns1-ns2.+157+02839.private
Private-key-format:v1.2
Algorithm:157(HMAC_MD5)
Key:sv9MOKtAsj3ZAiSi+8aKjw==
2. 建立密钥认证文件(ns1、ns2)
[root@ns1 ~]# vi /var/named/chroot/etc/transfer.key
key "ns1-ns2" {
algorithm hmac-md5;
secret "sv9MOKtAsj3ZAiSi+8aKjw==";
};
[root@ns1 ~]# chown root.named /var/named/chroot/etc/transfer.key
[root@ns1 ~]# chmod 640 /var/named/chroot/etc/transfer.key
3. 配置主DNS服务器(ns1)
1)主配置文件named.conf
[root@ns1 ~]# vi /var/named/chroot/etc/named.conf
include "../../etc/transfer.key"; #//加载密钥配置文件
options {
directory "/var/named";
version "No version for you!!"; #//隐藏版本查询
allow-transfer { key "ns1-ns2"; }; #//允许...传输,可以用acl
allow-query { 192.168.4.0/24; }; #//允许...查询,不能用acl
};
zone "mydomain.com" IN { #//正向主区域
type master;
file "mydomain.com.zone";
};
zone "4.168.192.in-addr.arpa" IN { #//反向主区域
type master;
file "192.168.4.arpa";
};
2)正、反向区域数据文件
[root@ns1 ~]# vi /var/named/chroot/var/named/mydomain.com.zone
$TTL 86400
@ SOA mydomain.com. root.mydomain.com. (
2012022301
4H
1H
2H
1D
)
@ IN NS ns1.mydomain.com.
IN NS ns2.mydomain.com.
ns1 IN A 192.168.4.111
ns2 IN A 192.168.4.112
www IN A 192.168.4.100
ftp IN A 192.168.4.121
......
* IN A 192.168.4.100
[root@ns1 ~]# vi /var/named/chroot/var/named/192.168.4.arpa
$TTL 86400
@ SOA ...
......
@ IN NS ns1.mydomain.com.
IN NS ns2.mydomain.com.
100 IN PTR
111 IN PTR ns1.mydomain.com.
112 IN PTR ns2.mydomain.com.
121 IN PTR ftp.mydomain.com.
......
3)启动named服务
[root@ns1 ~]# service named start ; chkconfig named on
4. 从DNS服务器(ns2)
1)主配置文件named.conf
[root@ns2 ~]# vi /var/named/chroot/etc/named.conf
include "../../etc/transfer.key"; #//加载密钥配置文件
server 192.168.4.111 { #//使用密钥与Master认证
keys { ns1-ns2; };
};
options {
directory "/var/named";
version "No version for you!!";
allow-transfer { none; };
allow-query { 192.168.4.0/24; };
};
zone "mydomain.com" IN {
type slave;
masters { 192.168.4.111; };
file "slaves/mydomain.com.zone";
};
zone "4.168.192.in-addr.arpa" IN {
type slave;
masters { 192.168.4.111; };
file "slaves/192.168.4.arpa";
};
2)启动named服务,验证区域文件
[root@ns2 ~]# service named start ; chkconfig named on
[root@ns2 ~]# ls /var/named/chroot/var/named/slaves/
192.168.4.arpa mydomain.com.zone
5. 客户机设置及查询
[root@client ~]# vi /etc/resolv.conf
search mydomain.com
nameserver 192.168.4.111
nameserver 192.168.4.112
[root@client ~]# nslookup
......
Name:
Address: 192.168.4.100
[root@client ~]# nslookup 192.168.4.100
......
100.4.168.in-addr.arpa name =
二、View视图设置
1. 调整named.conf配置文件
[root@ns1 ~]# vi /var/named/chroot/etc/named.conf
acl "internal" { 127.0.0.0/8; 192.168.4.0/24; };
options {
directory "/var/named";
version "No version for you!!";
......
};
view "secnet" { #//第一个视图,最先匹配
match-clients { "internal"; };
recursion yes; #//允许递归查询
zone "mydomain.com" IN {
type master;
file "mydomain.com.zone.intr";
};
......
}
view "other" { #//默认视图放最后
match-clients { any; };
recursion no; #//禁止递归查询
zone "mydomain.com" IN {
type master;
file "mydomain.com.zone.other";
};
......
}
2. 为每个视图分别建立区域数据文件
1)mydomain.com.zone.intr
......
2)mydomain.com.zone.other
3. 调整从DNS服务器,参考步骤1。
......(略)
##############################################################################
—— 补充,关于多个View的同名区域主从同步问题
1. Slave
1)为每个View配一个IP地址(可以是eth0:0、eth0:1等虚拟接口)。
2)在每个View内表明己方用于同步的源地址。
view "secret" {
transfer-source IP1;
......;
};
view "other" {
transfer-source IP2;
......;
};
2. Master:
通过match-clients区分视图
view "secret" {
match-clients { IP1; !IP2; ...; };
allow-transfer { IP1; };
......;
};
view "other" {
match-clients { IP2; !IP1; ...; };
allow-transfer { IP2; };
......;
};
************************************************************
阅读(2614) | 评论(1) | 转发(0) |