4

The Goal

I'm wanting to configure bind9 on Ubuntu 12.04 to log out to a named pipe. The purpose is to redirect logging to the syslog-ng service.

The Problem

My problem is that when I direct the logging channel to the named pipe file, the bind service will not start. This is the logging clause, where query.log is the FIFO file :

logging {
  channel query.log {
      file "/var/log/named/query.log";
      severity info;
      print-time yes;
      print-category yes;
  };

  category queries  { query.log; };
  category ....
};

This is the output found in syslog:

Jun 12 12:37:53 hostname named[19400]: isc_file_isplainfile '/var/log/named/query.log' failed: invalid file
Jun 12 12:37:53 hostname named[19400]: configuring logging: invalid file
Jun 12 12:37:53 hostname named[19400]: loading configuration: invalid file

What I've Tried

I have validated that the permissions are correct, and logging to a standard file works without issue. I have also validated that I can send data through the pipe, by running

sudo -u bind bash -c 'echo "test" > /var/log/named/query.log'

I see the data appear in syslog-ng as expected. I've also set /usr/sbin/named to both complain and disabled in Apparmor, yet I'm still experiencing the issue.

Help?

Is what I'm proposing to do possible? If so, any pointers on what I might be doing wrong.

jiwanrai
  • 411
  • 4
  • 5

1 Answers1

0

1) Answer for the question

Bind9 logging to named

a) I was looking for solution in BIND9-s source code, and I found that it can't be done without source modification.

b) The closest solution is to log into stderr:

logging {
  channel query.log {
   stderr;
   severity info;
   print-time yes;
   print-category yes;
 };

 category queries  { query.log; };
};

and redirect it into named pipe by modification BIND9 startup script. I did it by modification /etc/init.d/bind9:

  • you need to find startup command. In my case it was line №64

    if start-stop-daemon --start --oknodo --quiet --exec '/usr/sbin/named' \

    --pidfile ${PIDFILE} -- $OPTIONS"; then

  • and modify it like:

    if start-stop-daemon --start --oknodo --quiet --exec '/bin/bash' \

    --pidfile ${PIDFILE} -- -c "/usr/sbin/named -g $OPTIONS 2> /var/log/named/queries.log $;"; then

2) Answer for the purpose:

bind9 allow you to log directly into syslog by config:

logging {
 category queries { default_syslog; };
};

The default_syslog chanel is writing logs into syslog by default.

Or you can write explicit config:

logging {
  channel query.log {
   syslog daemon;
   severity info;
   print-time yes;
   print-category yes;
 };

 category queries  { query.log; };
};

See logging config manual: http://www.zytrax.com/books/dns/ch7/logging.html

Youw
  • 799
  • 6
  • 11