[Networkmanager] Check if a DHCP server is responsive

Frédéric Martinsons frederic.martinsons at gmail.com
Thu May 4 12:33:07 UTC 2023


Le jeu. 4 mai 2023, 14:06, Thomas Haller <thaller at redhat.com> a écrit :

> Hi,
>
> On Thu, 2023-05-04 at 11:47 +0200, Frédéric Martinsons wrote:
> > 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 ?
>
> I don't see how such functionality would fit into NetworkManager. But
> maybe it does, if you have a specific suggestion please make it.
>
> Instead, I would use/build a separate tool for that. If it's a specific
> tool for that purpose, then the API would be simple. If it's a more
> general tool (e.g. integrate it into ISC dhclient) then it is already
> more complicated to make the functionality general purpose and fit it
> into a more general tool.
>

It could be generic since during my search, I found several request for
such a case (but people seems happy with the tools that are already
available like Nagios plug-in)

There are several DHCP client libraries and implementations. For
> example there is https://github.com/nispor/mozim
>
> I would actually use nettools' n-dhcp4 library (which you already
> investigated) and build a specialized one-purpose tool on top of that.
> That should be relatively straight forward, and if API is missing for
> making it happen, it probably can be accepted upstream.
>
> https://github.com/nettools/n-dhcp4
>
>
> Thomas
>

This is exactly what I have done (thank you very much for the code in NM
which help me to achieve that), I just wanted to know if someone here could
be interdested to have that ship directly in NM but I heard you, loud and
clear.

 Thank you Thomas for the answer.

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/networkmanager/attachments/20230504/84681032/attachment.htm>


More information about the Networkmanager mailing list