8

I am switching from Debian’s ifupdown to systemd-networkd, and it mostly works fine. One missing bit is that upon every network change, I want to call killall -ARLM tinc, so that my VPN is going up in a timely manner.

Does systemd or systemd-networkd provide such functionality? How would I use it?

3

Tinc should be updated as a systemd unit instead of sending direct signals. To achieve this one needs to configure their unit files to be chained with the appropriate Require=, Before=, and After= lines in the [Unit] section. Also ensure that you set the correct WantedBy= for network services. (ie. WantedBy= { network.target, network-online.target, network-pre.target } instead of multi-user.target)

This allows one to execute systemctl restart systemd-networkd.service to restart your network. Combined this with systemd-resolvd, udev/dbus (plus wpa_supplicant@nic.service when on wifi) and one's network just works.

Be sure to read the articles on switching to systemd-networkd and unit dependancies. This is also a way to send signals to your systemd.service units via the systemctl kill command as documented in the systemd for administartors guide

  • I don’t really follow. So if tinc is run as a systemd service, I can use systemctl kill to deliver the signal. But I do not see how to trigger that on a network configuration change. – Joachim Breitner Apr 23 '15 at 19:18
  • You wouldn't use systemd's signalling only the targets and relationship dependencies. Thus once your network interface is up this signals (internally to systemd) the other dependencies in the network.target then network-online.target to kick off that unit. so just have tinc.service include Requires=systemd-networkd.service and WantedBy=network-online.target then when systemd-networkd kicks off that will bring up the nic and tun interface, establish an IP address, and then signal to tinc to start or restart as needed. – Dwight Spencer Apr 23 '15 at 19:48
  • Me too couldn't find a way to trigger a service restart, because network-online.target doesn't stop on disconnect (should file a bug report for this actually...). I resorted to a /etc/NetworkManager/dispatcher.d/ script that contains case "$2" in up|connectivity-change) if /usr/bin/nm-online -qx; then systemctl reload autossh.service fi;; esac – eMPee584 Nov 29 '17 at 19:05
0

This is currently not possible. However you can only use systemd-networkd-wait-online.service as a dependency on boot to reconfigure tinc. In my experience tinc will react quickly on changes in the network configuration. At least on linux it could use rtnetlink to listen for interfaces changes.

0

I'm using networkd-dispatcher to run events after interface status changes:

Networkd-dispatcher is a dispatcher daemon for systemd-networkd connection status changes. This daemon is similar to NetworkManager-dispatcher, but is much more limited in the types of events it supports due to the limited nature of systemd-networkd.

Link to Githib

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.