[Networkmanager] Check if a DHCP server is responsive
Frédéric Martinsons
frederic.martinsons at gmail.com
Thu May 4 09:47:28 UTC 2023
Hello list,
I would like to add some monitoring of the dhcp servers via the machines
which request ip addresses from it (no access to the server itself)
For the moment, we are only aware of the outage of this server when the
lease expired.
I first check if NM has a dbus api for that and didn't find one, the I use
a Nagios plug-in as a standalone program (
https://github.com/nagios-plugins/nagios-plugins/blob/master/plugins-root/check_dhcp.c)
but it seems to not work on all cases I have (strong firewalling among
other).
I don't want to use nmap or other external tools that I didn't already have
on the machines (I have strong constraint on the size available)
Since our machines used NM to manage ethernet , I decided to look at the
code to know how the things are handled and if a can have the
possibility to "ping" (just emit a DISCOVER and listen for OFFER without
accepting the lease). I first came up with a solution that involves
instantiating a NMDhcpClient to use an internal dhcp mechanism. It worked
but I had to patch NM code to avoid messing with the system (I don't want
to read the already accepted lease or modify the current lease). Moreover
my binary had to link with almost all NM code which makes it very big.
I finally came up with a minimal solution by mimicking what is done in
nm-dhcp-nettools.c and talking directly to the n-dhcp4 library.
Long story short, I'm wondering if this "ping dhcp" capability is a feature
fitted to enter as a standalone binary (or a dedicated DBus endpoint) in NM
code ?
What do you think ?
Thanks in advance for your insights.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/networkmanager/attachments/20230504/141d658e/attachment.htm>
More information about the Networkmanager
mailing list