Linux systemd and Network Status: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 6: Line 6:


* [[Systemd_Concepts#systemd_and_network_status|systemd Concepts]]
* [[Systemd_Concepts#systemd_and_network_status|systemd Concepts]]
* [[Linux Network Concepts#Subjects|Linux Network Concepts]]
* [[Relationship between Network Manager and Network Scripts]]
=Overview=
systemd-based boot scripts rely on the ''$network boot facility'' to express their dependency on the network status (note that '$' is the conventional way to refer to a boot facility and it does not imply variable substitution). According to the [http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/facilname.html Linux specifications], $network can be used to signal that basic network support is available. This definition is rather vague.
In systemd, three target units take the role of $network:
* <span id='network_target'></span><tt>network.target</tt>, if reached, indicates that the network management stack is up. This carries little meaning during startup: whether any network interface is already configured is undefined. The primary purpose is to be used during shutdown. Shutdown ordering of units in systemd is in reverse of the startup ordering, any unit that declares <tt>After=network.target</tt> can be sure it is stopped ''before'' the network is shut down. This allows services to cleanly terminate connections. Those services should place an <tt>After=network.target</tt> dependency and avoid <tt>Wants=network.target</tt> or even <tt>Requires=network.target</tt>. <tt>network.target</tt> is a ''passive'' unit: it cannot be started directly, it is not pulled by any service that wants to make use of the network, but by the network management service ([[NetworkManager]]) itself.
* <span id='network-online_target'><tt>network-online.target</tt> is a target that actively waits until the network is "up". The definition of "up" depends on the network management software (not necessarily [[NetworkManager]], the target is reached even if [[NetworkManager]] is absent). <tt>network-online.target</tt> usually indicates a configured, routable IP address of some kind. The primary purpose is to delay activation of services until the network is up. <tt>network-online.target</tt> is an ''active'' target, meaning that it may be pulled by services requiring the network to be up, but it is not pulled by the network management service itself ([[NetworkManager]]). By default, all remote mounts declared in [[/etc/fstab]] pull this service in.
* <span id='network-pre_target'><tt>network-pre.target</tt> <font color=red>TODO https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/</font>.

Latest revision as of 21:22, 22 May 2017

External

Internal

Overview

systemd-based boot scripts rely on the $network boot facility to express their dependency on the network status (note that '$' is the conventional way to refer to a boot facility and it does not imply variable substitution). According to the Linux specifications, $network can be used to signal that basic network support is available. This definition is rather vague.

In systemd, three target units take the role of $network:

  • network.target, if reached, indicates that the network management stack is up. This carries little meaning during startup: whether any network interface is already configured is undefined. The primary purpose is to be used during shutdown. Shutdown ordering of units in systemd is in reverse of the startup ordering, any unit that declares After=network.target can be sure it is stopped before the network is shut down. This allows services to cleanly terminate connections. Those services should place an After=network.target dependency and avoid Wants=network.target or even Requires=network.target. network.target is a passive unit: it cannot be started directly, it is not pulled by any service that wants to make use of the network, but by the network management service (NetworkManager) itself.
  • network-online.target is a target that actively waits until the network is "up". The definition of "up" depends on the network management software (not necessarily NetworkManager, the target is reached even if NetworkManager is absent). network-online.target usually indicates a configured, routable IP address of some kind. The primary purpose is to delay activation of services until the network is up. network-online.target is an active target, meaning that it may be pulled by services requiring the network to be up, but it is not pulled by the network management service itself (NetworkManager). By default, all remote mounts declared in /etc/fstab pull this service in.