Systemd/networkd/dispatcher: Difference between revisions

From NixOS Wiki
imported>Onny
Created page with "[https://gitlab.com/craftyguy/networkd-dispatcher Networkd-dispatcher] is a dispatcher service for systemd-networkd connection status changes. This daemon is similar to Networ..."
 
imported>Onny
mNo edit summary
Line 29: Line 29:
</syntaxhighlight>
</syntaxhighlight>


Please refer [https://github.com/evilsocket/opensnitch/wiki/Rules upstream documentation] for configuration syntax and additional examples.
Please refer [https://gitlab.com/craftyguy/networkd-dispatcher upstream documentation] for configuration syntax and additional examples.


[[Category:Networking]]
[[Category:Networking]]

Revision as of 13:45, 19 February 2023

Networkd-dispatcher is a dispatcher service 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.

Note: Parts of this instruction and module are not yet stable and will be available in the upcoming NixOS 23.05 release.

Installation

Add following line to your system configuration to install and enable Networkd-dispatcher

services.networkd-dispatcher.enable = true;

Configuration

In the following example we're going to create a script which will restart the Tor daemon everytime the interface wlan0 establishes a new successfull connection to a wifi network.

/var/lib/networkd-dispatcher/routable.d/00-restart-tor.sh
#!/usr/bin/env bash
if [[ $IFACE == "wlan0" && $AdministrativeState == "configured" ]]; then
    systemctl restart tor
fi
exit 0

Adjusting file permissions for the script to work

chmod 755 /var/lib/networkd-dispatcher/routable.d/00-restart-tor
chown root /var/lib/networkd-dispatcher/routable.d/00-restart-tor

Please refer upstream documentation for configuration syntax and additional examples.