V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
tsuibin
V2EX  ›  Linux

linux dhcp 日志记录的内容是否可以配置?

  •  
  •   tsuibin ·
    tsuibin · 2014-03-21 16:26:48 +08:00 · 3668 次点击
    这是一个创建于 3904 天前的主题,其中的信息可能已经有所发展或是发生改变。
    现在有一台DHCP服务器,使用rsyslog记录日志

    配置为:
    /etc/rsyslog.d$ cat 30-dhcpd.conf
    local7.* -/var/log/dhcpd.log

    记录内容为:
    ar 18 07:58:44 00-0e-0c-ab-6c-90 dhcpd: DHCPDISCOVER from 0c:30:21:f1:37:5c via eth2
    Mar 18 07:58:45 00-0e-0c-ab-6c-90 dhcpd: DHCPOFFER on 192.168.0.85 to 0c:30:21:f1:37:5c (iPhone) via eth2
    Mar 18 07:58:46 00-0e-0c-ab-6c-90 dhcpd: Can't create new lease file: Permission denied
    Mar 18 07:58:46 00-0e-0c-ab-6c-90 dhcpd: DHCPREQUEST for 192.168.0.85 (192.168.0.1) from 0c:30:21:f1:37:5c (iPhone) via eth2
    Mar 18 07:58:46 00-0e-0c-ab-6c-90 dhcpd: DHCPACK on 192.168.0.85 to 0c:30:21:f1:37:5c (iPhone) via eth2
    Mar 18 08:35:23 00-0e-0c-ab-6c-90 dhcpd: DHCPDISCOVER from 48:28:2f:a6:86:37 via eth2
    Mar 18 08:35:24 00-0e-0c-ab-6c-90 dhcpd: DHCPOFFER on 192.168.0.61 to 48:28:2f:a6:86:37 (android_f4d80b78fa14bc2d) via eth2
    Mar 18 08:35:25 00-0e-0c-ab-6c-90 dhcpd: DHCPREQUEST for 192.168.0.61 (192.168.0.1) from 48:28:2f:a6:86:37 (android_f4d80b78fa14bc2d) via eth2
    Mar 18 08:35:25 00-0e-0c-ab-6c-90 dhcpd: DHCPACK on 192.168.0.61 to 48:28:2f:a6:86:37 (android_f4d80b78fa14bc2d) via eth2
    Mar 18 08:40:21 00-0e-0c-ab-6c-90 dhcpd: DHCPREQUEST for 192.168.0.61 from 48:28:2f:a6:86:37 (android_f4d80b78fa14bc2d) via eth2



    现在有没有办法通过配置,只记录DHCPACK的条目?
    还是没有办法配置,只能后期处理?
    1 条回复    1970-01-01 08:00:00 +08:00
    tsuibin
        1
    tsuibin  
    OP
       2014-03-21 16:44:27 +08:00
    要是不能配置 就只能从源码下手了

    dhcp-4.2.6/omapip/errwarn.c

    128 /* Log a note... */
    129
    130 int log_info (const char *fmt, ...)
    131 {
    132 va_list list;
    133
    134 do_percentm (fbuf, fmt);
    135
    136 /* %Audit% This is log output. %2004.06.17,Safe%
    137 * If we truncate we hope the user can get a hint from the log.
    138 */
    139 va_start (list, fmt);
    140 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
    141 va_end (list);
    142
    143 #ifndef DEBUG
    144 syslog (log_priority | LOG_INFO, "%s", mbuf);
    145 #endif
    146
    147 if (log_perror) {
    148 IGNORE_RET (write (STDERR_FILENO, mbuf, strlen (mbuf)));
    149 IGNORE_RET (write (STDERR_FILENO, "\n", 1));
    150 }
    151
    152 return 0;
    153 }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5509 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 08:39 · PVG 16:39 · LAX 00:39 · JFK 03:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.