云服务器

DNS的最终归属管理篇

2020-04-26 10:40:49 70

前言

上一期讲了通过bind+mysql的结合,打造出通过数据库管理的一个既高性能又方便维护的智能DNS系统;这期我们再讲讲增加DNS远程管理的功能和外部解析能力,可以进一步舒服的维护我们的DNS系统。

 

一、远程管理服务器

1、在被管理的服务器上生成密钥
cd /var/named/chroot/etc
rndc-confgen -a -b 128 -k mrndc-key -c mrndc.key -s 172.16.0.254 \主服务器上运行
cat mrndc.key

key “mrndc-key” {
algorithm hmac-md5;
secret “zL1WPhVyoDaiDVh5/2XDuQ==”;
};

controls {
inet 172.16.10.222 port 953 allow { 172.16.0.254; } keys { “mrndc-key”; };
};

chown named:named /var/named/chroot/etc/mrndc.key
vim /etc/named.conf
include “/etc/mrndc.key”;

rndc-confgen -a -b 128 -k srndc-key -c srndc.key -s 172.16.0.254 \从服务器上运行

2、在控制服务器上进行配置
vim /etc/rndc.conf

key “mrndc-key” {
algorithm hmac-md5;
secret “zL1WPhVyoDaiDVh5/2XDuQ==”;
};

key “srndc-key” {
algorithm hmac-md5;
secret “MJqtxmTI9LQbmdn9R7DHtg==”;
};

options {
default-key “mrndc-key”;
default-server 172.16.10.222;
default-port 953;
};

server 172.16.10.222 {
key “mrndc-key”;
};

server 172.16.10.223 {
key “srndc-key”;
};

通过以下命令,您就可以轻松在控制服务器上对DNS服务器进行服务管理操作!
/opt/bind9/sbin/rndc status
/opt/bind9/sbin/rndc stop
/opt/bind9/sbin/rndc start
/opt/bind9/sbin/rndc restart
/opt/bind9/sbin/rndc reload

 

二、增加外部解析能力

产品的需求总是无穷无尽的,很多人想,这个智能dns系统,这个DNS我不仅仅是内部使用,还必须要有外部解析的能力,其实很简单,在option里加几条简单的语句,就能轻松解决您的问题。
options {

        directory "/var/cache/bind9";
        // If there is a firewall between you and nameservers you want
        // to talk to, you may need to fix the firewall to allow multiple
        // ports to talk.  See http://www.kb.cert.org/vuls/id/800113
        // If your ISP provided one or more IP addresses for stable 
        // nameservers, you probably want to use them as forwarders.  
        // Uncomment the following block, and insert the addresses replacing 
        // the all-0's placeholder.
        // forwarders {
        //      0.0.0.0;
        // };
        version "UnKnow";
        listen-on { 127.0.0.1; 121.201.11.16; 121.201.11.17; };
        auth-nxdomain no;    # conform to RFC1035
        listen-on-v6 { none; };
        //allow-recursion { any; };
        allow-query { any; };
        //allow-query-cache { any; };
        recursion yes;
        forwarders { 114.114.114.114; };
        forward first;
        max-cache-ttl 604800;

};

DNS系统我们暂时就讲到这一期, 如果还需要更深入的探讨DNS或者其他应用服务,可关注我们睿江云计算的公众号,学习各种技术干货、硬货。

睿江云官网链接:www.eflycloud.com

上一篇: 无

微信关注

获取更多技术咨询