为什么当 bind9 为 777 时会因权限被拒绝错误而拒绝连接

Ali*_*eza 4 linux bind dns-zone

这些问题没有帮助:

https://askubuntu.com/questions/172030/how-to-allow-bind-in-app-armor
无法启动 BIND9

我想开始bind9并看到它给出了syslog以下拒绝的许可:

Feb  8 09:37:24 aname named[27278]: automatic empty zone: A.E.F.IP6.ARPA
Feb  8 09:37:24 aname named[27278]: automatic empty zone: B.E.F.IP6.ARPA
Feb  8 09:37:24 aname named[27278]: automatic empty zone: 8.B.D.0.1.0.0.2.IP6.ARPA
Feb  8 09:37:24 aname named[27278]: command channel listening on 127.0.0.1#953
Feb  8 09:37:24 aname named[27278]: command channel listening on ::1#953
Feb  8 09:37:24 aname named[27278]: isc_stdio_open '/var/log/bind9/query.log' failed: permission denied
Feb  8 09:37:24 aname named[27278]: configuring logging: permission denied
Feb  8 09:37:24 aname named[27278]: loading configuration: permission denied
Feb  8 09:37:24 aname named[27278]: exiting (due to fatal error)
Feb  8 09:37:24 aname kernel: [1984823.682079] type=1400 audit(1454924244.439:45): apparmor="DENIED" operation="open" profile="/usr/sbin/named" name="/var/log/bind9/query.log" pid=27279 comm="named" requested_mask="c" denied_mask="c" fsuid=109 ouid=0
Run Code Online (Sandbox Code Playgroud)

为什么它permission error在 777 时给出?

我想可能是由于zones目录,所以我也检查了它:

4 drwxr-sr-x  2 root root 4096 Feb  7 18:45 zones
Run Code Online (Sandbox Code Playgroud)

我检查了区域文件,/usr/sbin/named-checkconf但没有在终端上打印出错误。

内容bind9

4 -rw-r--r--  1 root root 2389 Jan 18 14:04 bind.keys
4 -rw-r--r--  1 root root  237 Jan 18 14:04 db.0
4 -rw-r--r--  1 root root  271 Jan 18 14:04 db.127
4 -rw-r--r--  1 root root  237 Jan 18 14:04 db.255
4 -rw-r--r--  1 root root  353 Jan 18 14:04 db.empty
4 -rw-r--r--  1 root root  270 Jan 18 14:04 db.local
4 -rw-r--r--  1 root root 3048 Jan 18 14:04 db.root
4 -rw-r--r--  1 root bind  464 Feb  7 17:56 named.conf
4 -rw-r--r--  1 root bind  490 Jan 18 14:04 named.conf.default-zones
4 -rw-r--r--  1 root bind  333 Feb  7 18:47 named.conf.local
4 -rw-r--r--  1 root bind  455 Feb  7 18:33 named.conf.options
4 -rw-r--r--  1 root bind  890 Feb  7 13:22 named.conf.options.bak
4 -rw-r-----  1 bind bind   77 Feb  7 13:22 rndc.key
4 drwxr-sr-x  2 root root 4096 Feb  7 18:45 zones
4 -rw-r--r--  1 root root 1317 Jan 18 14:04 zones.rfc1918
Run Code Online (Sandbox Code Playgroud)

编辑2:

ls -las /var/lib/bind/ 输出:

4 -rw-r--r--  1 root root   53 Feb  7 13:22 bind9-default.md5sum
Run Code Online (Sandbox Code Playgroud)

编辑 3:
我有apparmor,这与文件权限有关吗?

这个问题几乎解决了我的问题:https :
//askubuntu.com/questions/469866/bind-fatal-error-cant-open-custom-log

有些目录不存在,所以我创建了它们。路径named.conf.options是错误的,我更正了它们以指向一个存在的文件。

问题解决了!

Pet*_*r H 6

您的输出中存在错误:

Feb  8 09:37:24 aname kernel: [1984823.682079] type=1400 audit(1454924244.439:45): apparmor="DENIED" operation="open" profile="/usr/sbin/named" name="/var/log/bind9/query.log" pid=27279 comm="named" requested_mask="c" denied_mask="c" fsuid=109 ouid=0
Run Code Online (Sandbox Code Playgroud)

添加一个

/var/log/bind9/query.log rw,
Run Code Online (Sandbox Code Playgroud)

节到/etc/apparmor.d/usr.sbin.named,重新启动 apparmor 并绑定服务,您就可以开始了。

并恢复日志文件的文件系统权限。