DNS controls 语句

来源:互联网 发布:mac 查询端口 编辑:程序博客网 时间:2024/06/06 02:29
文章转自:http://blog.sina.com.cn/s/blog_6c2e6f1f0100l982.html
controls语句规定了rndc如何控制一个正在与行的named进程。rndc可以启动和停止named,转储其状态,将其转入调试模式等。
rndc是一个网络程序,如果配置不正确非常危险。
 
语法是:
controls {
  inet ip_addr port ip-port allow { address_match_list } keys {key_list };
如果没有定义port子句指定端口,那么rndc使用默认端口953
 
例子:
[root@test1test]# cat/etc/named.conf

options {
         version "i donot know";
         directory "/var/named";
         recursionno;       
         dump-file"/var/named/data/cache_dump.db";
         statistics-file "/var/named/data/named_stats.txt";
};
 key "rndckey"{
         algorithm hmac-md5;
         secret"Wpsjg97qGN/y5R3dLq1wb+fWqupxFaIllL0E159Z0DQ=";
 };
 
 controls {
         inet 127.0.0.1 port 953
              allow { 127.0.0.1; } keys { "rndckey"; };

 zone "." {
         type hint;
         file "named.ca";
};
 
.....
 
例中的key由rndc-confgen命令输出:
[root@test1 test]#rndc-confgen
# Start of rndc.conf
key "rndckey" {
       algorithm hmac-md5;
       secret "Wpsjg97qGN/y5R3dLq1wb+fWqupxFaIllL0E159Z0DQ=";
};
 
options {
       default-key "rndckey";
       default-server 127.0.0.1;
       default-port 953;
};
# End of rndc.conf
 
# Use with the following innamed.conf, adjusting the allow list as needed:
# key "rndckey" {
     algorithm hmac-md5;
     secret "Wpsjg97qGN/y5R3dLq1wb+fWqupxFaIllL0E159Z0DQ=";
# };
#
# controls {
     inet 127.0.0.1 port 953
             allow { 127.0.0.1; } keys { "rndckey"; };
# };

# End of named.conf
其中被#注释掉的就是加到named.conf中的行,他们能让named和rndc一起工作。
 
 
或者运行rndc-confgen -a -b256就会生成文件 /etc/rndc.key,其中包括:
key "rndckey" {
       algorithm hmac-md5;
       secret "Wpsjg97qGN/y5R3dLq1wb+fWqupxFaIllL0E159Z0DQ=";
};
这个文件模式为600,属主为named或者root,然后使用include语句把它加到named.conf中,例如:
[root@test1test]# more/etc/named.conf
options {
       directory "/var/named";
       dump-file "/var/named/data/cache_dump.db";
       statistics-file "/var/named/data/named_stats.txt";
};
include "/etc/rndc.key";
0 0
原创粉丝点击