Skip to content

Commit

Permalink
tree: Fix network startup
Browse files Browse the repository at this point in the history
See [1].

The network service providers (network.service, mxvlan.service,
unbound.service) are pulled from multi-user.target (not from
network.target).

network.service pulls network.target so that other services might use
"After=network.target" (only for shutdown order).

network.service, which has DefaultDependencies=no, needs to order iteslf
behind sysinit.target, so that the network devices are available.

[1]: https://systemd.io/NETWORK_ONLINE/
  • Loading branch information
donald committed Jul 4, 2023
1 parent 4c604b9 commit 1648ac4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions misc_systemd_units/mxvlan.service
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Unit]
Wants=network.service
After=network.service
DefaultDependencies=no
After=sysinit.target
Before=network.target

[Service]
Expand All @@ -11,5 +11,5 @@ ExecStop=/usr/sbin/mxvlanctl stop
ExecReload=/usr/sbin/mxvlanctl restart

[Install]
WantedBy=network.target
WantedBy=multi-user.target

5 changes: 4 additions & 1 deletion misc_systemd_units/network.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[Unit]
DefaultDependencies=no
After=sysinit.target
Before=network.target
Wants=network.target

[Service]
EnvironmentFile=/etc/local/mxhost.conf
Expand All @@ -12,4 +15,4 @@ ExecStart=/sbin/ip route add default via 141.14.16.128
ExecStop=/sbin/ip addr del ${MX_IPADDR}/20 dev ${MX_NETDEV}

[Install]
WantedBy=network.target
WantedBy=multi-user.target
6 changes: 4 additions & 2 deletions misc_systemd_units/unbound.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[Unit]
After=network.service
DefaultDependencies=no
After=sysinit.target
Before=network.target

[Service]
Type=forking
Expand All @@ -8,5 +10,5 @@ ExecStart=/usr/sbin/unbound
PIDFile=/var/unbound/unbound.pid

[Install]
WantedBy=network.target
WantedBy=multi-user.target

0 comments on commit 1648ac4

Please sign in to comment.