opnsense / core

OPNsense GUI, API and systems backend
https://opnsense.org/
BSD 2-Clause "Simplified" License
3.38k stars 759 forks source link

KEA dhcp client hostname to syslog #8054

Open thsundel opened 2 weeks ago

thsundel commented 2 weeks ago

Important notices

Before you add a new report, we ask you kindly to acknowledge the following:

Describe the solution you like

Would it be possible to send device hostname to syslog when device contacts server? At the moment it only sends mac adress, example: INFO [kea-dhcp4.dhcp4.0x33e0b3417b00] DHCP4_QUERY_LABEL received query: [hwtype=1 ma:ca:dd:re:ss:xx], cid=[ma:ca:dd:re:ss:xx], tid=0xa573c42c

Additional context

According to kea documentation this logger-name needs to be activated. kea-dhcp4.ddns, kea-dhcp6.ddns | core | Used by the DHCP server to log messages related to Client FQDN and Hostname option processing. It also includes log messages related to the relevant DNS updates.

https://kea.readthedocs.io/en/kea-2.2.0/arm/logging.html#the-name-string-logger

AdSchellevis commented 2 weeks ago

@thsundel can you update the ticket with documentation links you found? It helps when someone wants to implement the feature

AdSchellevis commented 1 week ago

I'm not sure if anything needs to be activated here, according to the documentation, loggers inherit from their parent:

The loggers form a hierarchy. For each program in Kea, there is a “root” logger, named after the program (e.g. the root logger for kea-dhcp4, the DHCPv4 server, is named kea-dhcp4). All other loggers are children of this logger and are named accordingly, e.g. the allocation engine in the DHCPv4 server logs messages using a logger called kea-dhcp4.alloc-engine.

My guess would be that messages you're searching for need a higher log level, you could try to change the level for testing purposes in:

https://github.com/opnsense/core/blob/db8005b18639e7d3e6e1ea6319a80eba811f9734/src/opnsense/mvc/app/models/OPNsense/Kea/KeaDhcpv4.php#L210

thsundel commented 6 days ago

Thank you for having a look at this feature request and yes I think you are correct. I had to set severity to DEBUG and debuglevel to 55 before hostname was included in the syslog message.

'severity' => 'INFO', 'debuglevel' => 55,

But that setting produces a lot of extra noise that I'm not interested in, I guess I'm out of luck then...

Thanks again for taking the time.

thsundel commented 6 days ago

But if I add the following then I get the result I'm looking for, without extra noise. I guess this is not possible to get into the distro and I have to manually change whenever I update OPNsense?

                     [
                        'name' => 'kea-dhcp4.ddns',
                        'output_options' => [
                            [
                                'output' => 'syslog'
                            ]
                        ],
                        'severity' => 'DEBUG',
                        'debuglevel' => 55,
                    ]
AdSchellevis commented 6 days ago

I guess the amount of noise is staggering when changing the top level collector (kea-dhcp4) to debug/55, that would be an easy addition, micro managing the options will be quite an effort to do properly, not sure I want to spend my time on that to be honest.