I am using the latest version of Centos. I have installed and configured Unbound for caching DNS. Testing it from client computers with dig and nslookup works.

However, if I set logfile in /etc/unbound/unbound.conf I can't see any logs. I have disabled Selinux and firewall.

When I debug this, there is a message in /var/log/messages:

error Could not open logfile /var/log/unbound: Permission denied

Also haven't any syntax error on the main configuration file of unbound

Now I try to solve this problem but I can't

Thanks in advance

  • 2
    Are you running unbound in a chroot? If so, is /var/log/messages available in that chroot? – Kusalananda Feb 19 '17 at 15:48

What's your logfile value? Am I right to assume it involves /var/log/unbound being a directory?

If so, make sure that directory exists, and that unbound runtime user may write in there.

mkdir -p /var/log/unbound
chown unbound:unbound /var/log/unbound

Otherwise, you may need to create unbound log file and set its permissions prior to starting unbound

touch /var/log/unbound
chown unbound:unbound /var/log/unbound
  • This Permission denied error is related to file ownership, but also directory ownership. Even if you chown unbound:unbound, there is a chance the permissions on /var/log/ might prevent unbound from writing to the file in that directory. Just another FYI for those who run into this issue. Personally I just redirected unbound.log to be located in /var/tmp/ because I'm the only person administering the server its running on. – Alby Jun 6 '20 at 12:54

Actually, it may not help. But i found a solution on another site. Unbound DNS caching server not loging.

Brief commands, if Link doesn't work. The permissions on the file are okay, but the problem was with apparmor.

So to fix the issue, we have to edit the settings:

vim /etc/apparmor.d/local/usr.sbin.unbound

Add this line (Here you should write a path to your "unbound.log" file. ):

# Site-specific additions and overrides for usr.sbin.unbound.
# For more details, please see /etc/apparmor.d/local/README.
/var/log/unbound/unbound.log rw,

Reload apparmor config and restart unbound services:

apparmor_parser -r /etc/apparmor.d/usr.sbin.unbound 
service unbound restart

It helps me, hope it helps you too.

  • This worked on Debian 10. One note though - the link in your 1st paragraph points to this site. Can you fix that? – 71GA Dec 23 '20 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.