[systemd-devel] dhcp address change callback?

Dan Williams dcbw at redhat.com
Mon Jan 25 08:25:37 PST 2016


On Mon, 2016-01-25 at 14:27 +0100, Lennart Poettering wrote:
> On Mon, 25.01.16 05:08, J Decker (d3ck0r at gmail.com) wrote:
> 
> > On Mon, Jan 25, 2016 at 4:43 AM, Lennart Poettering
> > <lennart at poettering.net> wrote:
> > > On Sat, 23.01.16 14:22, Johannes Ernst (johannes.ernst at gmail.com)
> > > wrote:
> > > 
> > > > Is there a way to receive a callback when a dhcp client-side IP
> > > > address changes?
> > > > 
> > > > Use case: dynamic DNS update.
> > > 
> > > On Linux changes regarding IP configuration are reported via rtnl
> > > (aka
> > > routing netlink). This works regardless how the IP address was
> > > required, and without any extra API from networkd.
> > > 
> > 
> > that's somewhat more useful information than 'there's hooks in C
> > for
> > it' Is there some standard daemon that listens and can bind to
> > these
> > events?
> > And even so; can't a few lines (configuration defintion, a variable
> > to
> > store a scriptname, and a call to exec the script like using a
> > systemd
> > unit to setup a network be added to a single place that already
> > does
> > the change?  Even if it's a systemd service that's added that in
> > turn
> > listens to rtnl?
> 
> Well, in systemd, a couple of daemons subscribe to rtnl, including
> networkd and resolved among others. However, none of them provide you
> with a concept of hooks for invoking scripts when events happen.
> 
> NetworkManager provides you some support for this, and other daemons
> might too, but they also take over control of an interface
> completely,
> not sure if that's what you want.

While it would be nice to attach metadata to addresses to indicate that
an address came from DHCP or RA or PPP or LL or whatever, the kernel
has no facility for that so users are stuck asking management daemons
like networkd or NetworkManager where the address came from if they
need to know.

At least in NetworkManager's case, it will quite happily co-exist with
any additional addresses and/or routes you assign to the interface
statically or otherwise, and it will reflect those in its D-Bus API,
dispatcher script environment, and command-line tools like nmcli.

Dan


More information about the systemd-devel mailing list