CentOS 5基于View和key加密传输编译安装Bind9 DNS主从服务器

测试环境:

主:192.168.79.130

从:192.168.79.128、

一、编译安装

这里采用编译安装,相比rpm方式安装效果更能了解其工作机制。

(下载源文件包)

#tar -zxvf bind-9.9.3.tar.gz (解压)

# cd bind-9.9.3 (进入解压出来的目录)

# ./configure –prefix=/usr/local/named –enable-threads –with-dlz-mysql

(进行编译,–perfix选项指定安装目录,–enable-threads选项用来打开线程支持以提高服务器性 能,–with-dlz-mysql选项用来启用区域的动态加载,适合大型的dns服务器系统,其他编译选项可输入./configure –help查看)
checking for MySQL DLZ driver… not found
configure: error: MySQL was not found in any of /usr /usr/local /usr/local/mysql /usr/pkg; use –with-dlz-mysql=/path

(系统中没有找到mysql开发头文件,CentOS下mysql开发头文件名称是mysql-devel,可以使用yum -y install mysql-devel命令安装)

# ./configure –prefix=/usr/local/named –enable-threads
#make && make install (编译完后进行安装,这个过程比较长,耐心等待下!)

# ls /usr/local/named/ (查看安装完后的目录)
bin etc include lib man sbin var首先生成一个控制key,用于主从同步数据加密的key。
#/usr/local/named/sbin/rndc-confgen -a -c linuxidc.key -k linuxidc

并也把生成的/ linuxidc.key传到主从服务器。

进入/usr/local/named/etc,将rndc.conf及named.conf生成

#/usr/local/named/sbin/rndc-confgen >/usr/local/named/etc/rndc.conf

(使用rndc-confgen命令生成rndc.conf文件,rndc主要用来通过网络控制bind9服务器,在能够控制一台bind服务器前,必须要建立双方的认证机制。)
# cat etc/rndc.conf

# Start of rndc.conf

key ”rndc-key” {

algorithm hmac-md5;

secret ”uLNAkFRNnTEChIurTi6bow==”;

};

options {

default-key ”rndc-key”;

default-server 127.0.0.1;

default-port 953;

};

# End of rndc.conf

# Use with the following in named.conf, adjusting the allow list as needed:

# key ”rndc-key” {

#      algorithm hmac-md5;

#      secret ”uLNAkFRNnTEChIurTi6bow==”;

# };

#

# controls {

#      inet 127.0.0.1 port 953

#              allow { 127.0.0.1; } keys { ”rndc-key”; };

# };

# End of named.conf
# tail -10 rndc.conf |head -9
# key ”rndc-key” {

#      algorithm hmac-md5;

#      secret ”uLNAkFRNnTEChIurTi6bow==”;

# };

#

# controls {

#      inet 127.0.0.1 port 953

#              allow { 127.0.0.1; } keys { ”rndc-key”; };

# };

把rndc.conf 中的key信息输出到 named.conf 中

#cd etc/

这里强调一下,rndc.conf与named.conf的key值必须完全一样,而且并不需要生

成rndc.key
# tail -10 rndc.conf |head -9 > name.conf (将rndc.conf的倒数第10行到倒数2行的文件重定向到name.conf )

去除这9行前面的#号
# cat name.conf
key ”rndc-key” {

algorithm hmac-md5;

secret ”uLNAkFRNnTEChIurTi6bow==”;

};

controls {

inet 127.0.0.1 port 953

allow { 127.0.0.1; } keys { ”rndc-key”; };

};
二、配置主服务器

修改主Bind配置文件,加载zhir.key

#vim named.conf

#acl ”linuxidc_acl” {192.168.1,10;192.168.2.10;};  #用acl做访问控制

options {

directory ”/usr/local/named/var/named”;

version ”0.0.0″;

datasize 40M;

pid-file ”/var/run/named.pid”;

listen-on port 53 {any;};

dump-file ”/usr/local/bind/var/data/cache_dump.db”;

statistics-file ”/usr/local/bind/var/data/bind_stats.txt”;

auth-nxdomain no;

notify yes;

also-notify { 192.168.79.128; };

transfer-format many-answers;

interface-interval 0;

allow-query { any; };

};

logging {

channel warning        {

file ”dns_warnings” versions 3 size 1240k;

severity warning;

print-category yes;

print-severity yes;

print-time yes;

};

channel general_dns        {

file ”dns_logs” versions 3 size 1240k;

severity info;

print-category yes;

print-severity yes;

print-time yes;

};

category default { warning; };

category queries { general_dns; };

};

include ”/usr/local/named/etc/linuxidc.key”;

#可以指定 “linuxidc”值

#key ”linuxidc” {

#  algorithm hmac-md5;

#  secret ”/3+UyJBAAS8WDus4DudqzQ==”;

#};

view ”view_linuxidc” {

        match-clients { any; };

        #match-clients { linuxidc_acl; };

server 192.168.79.128 {keys linuxidc;}; #从库加密认证

zone ”.” IN {

type hint;

file ”named.ca”;

};

zone ”localhost” IN {

type master;

file ”localhost.zone”;

};

type master;

file ”linuxidc.zone”;

allow-transfer { key linuxidc; };  #加密传输

};

};

key ”rndc-key” {

algorithm hmac-md5;

secret ”uLNAkFRNnTEChIurTi6bow==”;

};

controls {

inet 127.0.0.1 port 953

allow { 127.0.0.1; } keys { ”rndc-key”; };

};

相关推荐