ISC DHCP logging - different file for each subnet/pool

Bill Shirley bill at c3po.polymerindustries.biz
Fri Jun 2 20:07:02 UTC 2017


You can tailor the log messages to output the subnet type.

Add the two "subnet_type"s (below in your config) and this to dhcpd.conf:
on commit {
     log (    info,
         concat (
             "Subnet-type",    subnet_type,
.
.
         )
     );
}

Then in rsyslog.conf (just after the #### RULES #### line):
if $programname == 'dhcpd' then {
     if $msg contains 'Faculty' then {
         action(type="omfile" file="/var/log/dhcpd/dhcp-faculty.log")
         #  if $syslogseverity >= 4 then stop    # warning
         #  if $syslogseverity >= 5 then stop    # notice
         if $syslogseverity >= 6 then stop     # info
     }
     if $msg contains 'Student' then {
action(type="omfile" file="/var/log/dhcpd/dhcp-student.log")
         #  if $syslogseverity >= 4 then stop    # warning
         #  if $syslogseverity >= 5 then stop    # notice
         if $syslogseverity >= 6 then stop     # info
     }
}

This should split out the log messages.  Syslog facility 'notice' and above still go to
the regular log file.  Don't forget to restart or reload rsyslogd.

Bill

On 6/2/2017 9:11 AM, Fleming, Tony wrote:
>
> Can someone point me to a resource or provide a configuration example of how to log dhcp transaction (request/release/renew…) 
> for each of the defined subnet/pools to separate files?
>
> For example:
>
> Shared-network “Faculty”
>
>                 Subnet 10.10.10.0 netmask 255.255.255.0 {
>
            set subnet_type = "Faculty";
>
>                                 Option x
>
>                                 Option y
>
>                                 Range…
>
>                 }
>
> Shared-network “Student”
>
>                 Subnet 10.10.20.0 netmask 255.255.255.0 {
>
             set subnet_type = "Student";
>
>                                 Option x
>
>                                 Option y
>
>                                 Range …
>
>                 }
>
> Ideally it would be nice to log these transaction to:
>
> /var/log/dhcp/dhcp-faculty.log
>
> /var/log/dhcp/dhcp-student.log
>
>>
> Any pointers are much appreciated!
>
> Thank you.
>
>
>
> _______________________________________________
> dhcp-users mailing list
> dhcp-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/dhcp-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20170602/1af9a25f/attachment-0001.html>


More information about the dhcp-users mailing list