4

I would like to run a systemd oneshot service whenever my system gets a new IPv6 address assigned to it from the network router (this would be on boot, and periodically throughout its uptime).

Ideally, this event would be only for IPv6 address updates, and not include potential IPv4 address changes.

Is it possible to monitor networkd dbus activity for this kind of event with systemd?

My ultimate goal is to hit a dynamic DNS endpoint whenever this happens, so that this system's IPv6 DNS record avoids going stale.

  • Is the IPv6 addressing via SLAAC, or DHCPDv6? Because SLAAC addresses are not showing up in the output of a /etc/NetworkManager/dispatcher.d test script. – thrig Mar 24 '16 at 20:51
  • In my case SLAAC, but ideally this could cover both bases. – Bret Mar 10 '17 at 0:55
3

I wrote something like this many years ago, called (unimaginatively) autoddns.

It doesn't call a systemd service (I don't think systemd existed at the time!) but it does call an external process to perform the DNS update (nsupdate). It does however monitor IP address additions and deletions directly at the netlink level, which means it will pick them up no matter how they happen (manual administrative configuration, SLAAC, DHCP, Network Manager). It reacts instantaneously when changes occur. It does support filters (designed for automatically excluding things like link-local addresses), so you can get it to respect IPv6 address changes and ignore IPv4 ones, as you wish to do.

Perhaps you can use it or modify it to meet your needs. Most of the magic for detecting and reacting to IP address changes is in watchip.c, I think.

  • Looks promising! I'll try to mess around with it, but I'm not great with c. Perhaps a simple README would make it easier to get started with. – Bret Mar 10 '17 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.