安装系统顺便将dns服务安装好。
配置相关文件
cat host.conf
order bind,hosts
multi off
trim test.com
 
cat resolv.conf
nameserver 192.168.1.2
domain test.com
search a1.test.com test.com
option nochecknames rotate
 
生成rndc.conf文件
/usr/sbin/rndc-confgen > /etc/rndc.conf
Cat /etc/rndc.conf
 
# Start of rndc.conf
key "rndckey" {
        algorithm hmac-md5;
        secret "Pa1uzo6OxqGmSHrB4a3cgg==";
};
 
options {
        default-key "rndckey";
        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 "rndckey" {
#       algorithm hmac-md5;
#       secret "Pa1uzo6OxqGmSHrB4a3cgg==";
# };
#
# controls {
#       inet 127.0.0.1 port 953
#               allow { 127.0.0.1; } keys { "rndckey"; };
# };
# End of named.conf
创建 rndc.key文件,将rndc.conf文件中注释部分拷贝生成如下,
cat /etc/rndc.key
#key "rndckey" {
#       algorithm hmac-md5;
#       secret "BpVBPkwzbX2RmEJhd5pBwQ==";
#};
# Use with the following in named.conf, adjusting the allow list as needed:
key "rndckey" {
      algorithm hmac-md5;
      secret "yd/H/4rRKElPQwYShCWe6A==";
};
 
controls {
      inet 127.0.0.1 port 953
              allow { 127.0.0.1; } keys { "rndckey"; };
};
# End of named.conf
DNS添加域
vi /etc/named.conf
zone "test.com" IN {
        type master;
        file "anymusic.zone";
        allow-update { none; };
};
 
zone "1.168.192.in-addr.arpa" IN {
        type master;
        file "anymusic.arpa";
        allow-update { none; };
};
cp /var/named/localhost.zone /var/named/anymusic.zone
cp /var/named/named.local /var/named/anymusic.arpa 
vi anymusic.zone
$TTL    86400
@               IN SOA  a1.test.com       root.test.com (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
 
                IN NS           a1.test.com
a1              IN A            192.168.1.226
a1              IN AAAA         ::116
vi anymusic.arpa
$TTL    86400
@       IN      SOA     a1.test.com. root.test.com.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
              IN      NS      a1.test.com.
 
226       IN      PTR     a1.test.com.
检测:
Named –g
Named-checkconf
Named-checkzone test.com /var/named/anymusic.zone
启动 /etc/init.d/named start