CentOS 6: Configure bind logging with bind-chroot
I had troubles with daemons reloading while using bind-chroot+rsyslog+logrotate so I decided to update the post and paste my actual conf which doesn’t use them. Instead, you’ll find a sample named (bind-chroot) configuration to separate daemon messages from users queries. Everything has been tested with CentOS 6.{0..2} but it should works with any flavor of Unix-like systems. Note that with CentOS 6 bind chrooting is done by mount points, see mount | fgrep named while named is started ; you must not symlink configurations files and you should edit files directly under /etc. Though, you should not put your configuration directly in /etc/named.conf but include your own files under /etc/named/ using the include directive as shown bellow.
/etc/named.conf: Remove the logging{} block and include your own file
[...] include "/etc/named/named.conf.local";
/etc/named/named.conf.local:
[...]
logging {
channel log_dns {
file "/var/log/dns.log" versions 3 size 10m;
print-category yes;
print-severity yes;
print-time yes;
};
channel log_queries {
file "/var/log/dns_queries.log" versions 3 size 20m;
print-category yes;
print-severity yes;
print-time yes;
};
category default {log_dns;};
category queries {log_queries;};
category lame-servers { null;};
};
Log files are physically placed under /var/named/chroot/var/log/ so a lazy admin would want to symlink them in /var/log/:
ln -sf /var/named/chroot/var/log/dns.log /var/log/dns.log ln -sf /var/named/chroot/var/log/dns_queries.log /var/log/dns_queries.log