systemd systemd-unit systemd-service network

Source

  • use BindsTo= and After= in the [Unit] section and WantedBy= in [Install]

    [Unit]
    Description=Service depending on interface %I
    Wants=network-online.target
    BindsTo=sys-subsystem-net-devices-%i.device
    After=multi-user.target sys-subsystem-net-devices-%i.device network-online.target
     
    [Service]
    Type=simple
    ExecStart=...
     
    [Install]
    WantedBy=default.target sys-subsystem-net-devices-%i.device
  • use Wants=network-online.target and After=network-online.target to actually wait for the network to be online

    network-online.service unit does not monitor the online state of the system!

    This only works as a one-time concept during system start-up. The