Linux systemd and Network Status: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 14: Line 14:
In systemd, three target units take the role of $network:
In systemd, three target units take the role of $network:


* <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_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.


* <tt>network-online.target</tt>
* <tt>network-online.target</tt>


* <tt>network-pre.target</tt>
* <tt>network-pre.target</tt>

Revision as of 09:08, 17 April 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
  • network-pre.target