DNS服务/etc/rndc.key was found解决办法

问题:

[root@localhost ~]# rndc reload
rndc: neither /etc/rndc.conf nor /etc/rndc.key was found

解决办法:

RHEL6之后的版本配置好dns服务之后,会出现如下问题,rndc无法找到key,named服务是正常的

[root@localhost ~]# rndc reload
rndc: neither /etc/rndc.conf nor /etc/rndc.key was found

提示没有rndc.key,主要原因还是在RHEL6上没有caching-named这个包了,EL5上是把key包含在里面的。所以要手动创建key

1)创建key

[root@localhost ~]# rndc-confgen -r /dev/urandom -a

wrote key file "/etc/rndc.key"

2)更改权限

[root@localhost ~]# rndc status

rndc: connect failed: 127.0.0.1#953: connection refused


[root@localhost ~]# cat /etc/rndc.key 
key "rndc-key" {
	algorithm hmac-md5;
	secret "DpuAOAEoqIyi+zhOgnnneA==";
};


[root@localhost ~]# ls -l /etc/rndc.key 

-rw------- 1 root root 77 May  1 06:57 /etc/rndc.key


[root@localhost ~]# chown root:named /etc/rndc.key  #修改权限

[root@localhost ~]# chmod 644 /etc/rndc.key 

[root@localhost ~]# ls -l /etc/rndc.key 
-rw-r--r-- 1 root named 77 Jan 14 13:11 /etc/rndc.key

[root@localhost ~]# rndc status

rndc: connect failed: 127.0.0.1#953: connection refused


重启named服务!


[root@localhost ~]# systemctl restart named


验证成功:
[root@localhost ~]# rndc status
version: BIND 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.8 (Extended Support Version) <id:7107deb>
running on localhost.localdomain: Linux x86_64 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015
boot time: Fri, 14 Jan 2022 05:12:52 GMT
last configured: Fri, 14 Jan 2022 05:12:55 GMT
configuration file: /etc/named.conf
CPUs found: 1
worker threads: 1
UDP listeners per interface: 1
number of zones: 103 (97 automatic)
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
recursive clients: 0/900/1000
tcp clients: 2/150
server is up and running

[root@localhost ~]# rndc reload
server reload successful

posted @ 2022-01-10 23:18  咚咚小孩  阅读(565)  评论(0)    收藏  举报