ubuntu-12.04 - Bind9 记录到命名管道

标签 ubuntu-12.04 bind named-pipes syslog-ng

目标

我想在 Ubuntu 12.04 上配置 bind9 以注销到命名管道。目的是将日志记录重定向到 syslog-ng 服务。

问题

我的问题是,当我将日志记录 channel 定向到命名管道文件时,绑定(bind)服务将无法启动。
这是日志记录子句,其中 query.log 是 FIFO 文件:

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

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

这是在 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

我试过的

我已经验证权限是正确的,并且记录到标准文件可以正常工作。我还验证了我可以通过管道发送数据,方法是运行
sudo -u bind bash -c 'echo "test" > /var/log/named/query.log'

我看到数据按预期出现在 syslog-ng 中。
我还在 Apparmor 中将/usr/sbin/named 设置为提示和禁用,但我仍然遇到这个问题。

帮助?

我提议做的事情可能吗?如果是这样,任何关于我可能做错了什么的指针。

最佳答案

1) 回答问题

Bind9 logging to named



a)我在BIND9-s源代码中寻找解决方案,我发现不修改源代码无法完成。

b) 最接近的解决方案是登录 标准错误 :
logging {
  channel query.log {
   stderr;
   severity info;
   print-time yes;
   print-category yes;
 };

 category queries  { query.log; };
};

并通过修改 BIND9 启动脚本将其重定向到命名管道。我通过修改 做到了/etc/init.d/bind9 :
  • 你需要找到启动命令。就我而言,它是第 64 行

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

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

  • 并将其修改为:

    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) 为目的解答 :

    bind9 允许您通过配置直接登录到 syslog:
    logging {
     category queries { default_syslog; };
    };
    

    default_syslog channel 默认将日志写入 syslog。

    或者您可以编写显式配置:
    logging {
      channel query.log {
       syslog daemon;
       severity info;
       print-time yes;
       print-category yes;
     };
    
     category queries  { query.log; };
    };
    

    请参阅日志记录配置手册:
    http://www.zytrax.com/books/dns/ch7/logging.html

    关于ubuntu-12.04 - Bind9 记录到命名管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24184942/

    相关文章:

    rust - cargo 生成在 Ubuntu 20.04 上安装失败

    linux - sed 命令返回错误

    jQuery:取消绑定(bind)与 live() 绑定(bind)的事件

    javascript - 禁用具有 knockout 条件的悬停

    C++ 仿函数绑定(bind)

    java - 无法从 Java 中删除命名管道

    wxpython - 在 Ubuntu 12.04 上安装 wxPython

    windows - 有没有办法在 Windows 中嗅探命名管道流量?

    python - 在 Python 3.7 中使用和重叠命名管道

    php - HTML2PDF - fopen() 无法在第 6168 行打开流 : Permission denied in/html2pdf/_tcpdf_5. 0.002/tcpdf.php